Recent Notes

Displaying keyword search results 1 - 10
Created by James on January 16, 2012 10:05:10    Last update: January 16, 2012 10:06:13
There are two ways to get the submit button: Use the :submit selector (note the space between the form name and :submit ): $('#the-form-id :submit') Use attribute selector (also, space between form id and attribute selector): $('#the-form-id [type="submit"] ') // or $(... jQuery recommends the latter if you are concerned about performance: Because :submit is a jQuery extension and not part of the CSS specification, queries using :submit cannot take advantage of the performance boost provided by the native DOM querySelectorAll() method. For better performance in modern browsers, use [type="submit"] instead.
Created by Fang on December 06, 2011 19:03:25    Last update: December 07, 2011 08:54:11
Our custom tag, as implemented in the previous note , is broken when a template is used. Create a template file ( home-template.xhtml ): <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Stric... and a test page that uses it ( home.xhtml ): <?xml version="1.0" encoding="UTF-8"?> <ui:comp... Then request the page with URL: http://localhost:8080/facelet-demo/home.jsf?name=Jack . You'll find that our hello tag works inside ui:repeat but fails to get the value defined by ui:param ! What's the problem? Our hello tag implementation evaluated the EL with the wrong EL context! This is the corrected implementation: package com.example; import java.io.IOExcep...
Created by nogeek on November 03, 2010 20:52:49    Last update: November 23, 2011 08:54:44
My problem is simple: in my XML data, a timestamp is provided as a long integer (number of milliseconds since the "the epoch"). When I do XSLT, I want to display it as a readable string, such as "Mon Nov 01 18:08:48 CDT 2010". After hours of struggle, I found: It's not so easy to get the job done with JDK 1.6 There are tons of garbage on the web in this space (suggestions, code snippets that simply don't work) Simple Xalan extension functions was the only resource that's somewhat informative. Even there some of the examples don't work. Below is a list of what worked and what didn't. This works: <xsl:stylesheet version="1.0" xmlns:xsl="h... This does not (providing long value to Date constructor): <xsl:stylesheet version="1.0" xmlns:xsl="h......
Created by Fang on October 22, 2011 20:43:31    Last update: October 22, 2011 20:45:13
The only explanation of why some Java EE API classes are stripped off methods implementations I can find is this JBos forum post: What's the cause of this exception: java.lang.ClassFormatError: Absent Code? which also provides some workarounds for these crippled API classes. The explanation offered was: When one compiles, they want to run as well. By the way, we have been promoting full set of Java EE APIs which can only be used for compilation - they are stripped off method details. That way, user can't take those artifacts and try to use it in runtime. Honestly, I don't see any logic in those statements. This is the only place any such explanation is offered. Yes only from this JBos forum post! There's no public...
Created by Fang on October 22, 2011 19:51:05    Last update: October 22, 2011 20:31:48
I built a very basic JSF application and deployed to Tomcat 7.0.22, but it failed with this error: Caused by: java.lang.ClassFormatError: Absent Code... That looks weird and I wasn't able to find a sensible explanation! So I copied the jsf-api-2.1.jar , which was downloaded from the java.net Maven repository by Maven, into a temp folder. And tested it with this simple program: public class ClassFormatErrorTest { public ... I also copied servlet-api.jar from Tomcat's lib folder to the temp folder. Sure enough it failed with the same error: C:\tmp>java -cp .;jsf-api-2.1.jar;servlet-api.jar ... But when I replaced the javax.faces.webapp.FacesServlet class with one I compiled from source, the error disappears! Conclusions: The jar file jsf-api-2.1.jar from java.net Maven repository is good for compilation only (cannot be used...
Created by alfa on June 02, 2011 15:26:37    Last update: June 02, 2011 15:26:37
While doing some Java reflection code, I noticed the method Class.isSynthetic() , which the JavaDoc says returns " true if and only if this class is a synthetic class as defined by the Java Language Specification". However, there's no definition of "synthetic class" in the JLS ! The only thing that I can find that remotely resembles a definition is in the JVM spec , where it defines the synthetic attribute : "The Synthetic attribute is a fixed-length attribute in the attributes table of ClassFile (§4.1), field_info (§4.5), and method_info (§4.6) structures. A class member that does not appear in the source code must be marked using a Synthetic attribute." By this definition, a default constructor, which does not appear in the source code, should...
Created by alfa on May 26, 2011 21:16:22    Last update: June 02, 2011 14:39:57
Given a class A : class A { public int doWork(String s, int i... it is OK to call method doWork with both primitive types and the corresponding wrapping object types: new A().doWork("Hello", 1, false); new A().doWo... However, if you find method by parameter types with Java reflection, the types must match exactly, i.e., Class<?> c = Class.forName("A"); // This call f... This is a utility to find methods with compatible parameter types: import java.lang.reflect.*; import java.util.*;... Example usage: Method m = ReflectionUtil.getCompatibleMethod(c, "...
Created by alfa on May 26, 2011 20:20:50    Last update: May 26, 2011 20:20:50
You would never have guessed it. The test is: Modifier.isStatic(method.getModifiers()) ! Example code: import java.lang.reflect.Method; import java.la...
Created by Dr. Xi on March 30, 2011 13:43:05    Last update: March 30, 2011 13:45:27
Method 1 - use javap with verbose flag: $ javap HelloWorld -verbose | head Compiled fro... Method 2 - use a utility class: import java.io.*; import java.nio.ByteBuffer; ... According to the VM Spec , a Java class file has this structure: ClassFile { u4 magic; ...
Created by James on October 26, 2010 21:43:52    Last update: October 26, 2010 21:44:37
Use the unbind method to unbind an event. The following example unbinds three events: mouseenter , mouseleave and click . $('#control') .find('a') .css('cursor', 'def...
Previous  1 2 Next