Recent Notes

Displaying keyword search results 1 - 10
Created by Fang on July 25, 2012 12:52:40    Last update: September 14, 2012 13:37:57
Summarized from official JAX-WS documentation : Sending and Receiving SOAP Headers To send a SOAP header: HelloService helloService = new HelloService(); ... To receive a SOAP header: List<Header> inboundHeaders = bp.getInboundHeaders... Message logging On the client side, set system property: com.sun.xml.ws.transport.http.client.HttpTransport... On the server side, set system property: com.sun.xml.ws.transport.http.HttpAdapter.dump=tru... Propagation of Server-side Stacktrace Propagation of Stack trace is on by default. The whole stacktrace (including nested exceptions) is propagated in the SOAP Fault and the complete exception stacktrace is visible to the client as cause of SOAPFaultException . To turn off stack trace propagation, set this system property on the server: com.sun.xml.ws.fault.SOAPFaultBuilder.disableCaptu... Update: At least on the client side, the property name has been changed to: com.sun.xml.internal.ws.transport.http.client.Http... The messages are dumped to stdout . For...
Created by James on February 02, 2012 16:00:15    Last update: February 02, 2012 16:00:15
Video for Everybody seems to be a generic way to embed video in a web page, even without flash. This code snippet comes from that site. <!-- first try HTML5 playback: if serving as XML, ...
Created by zhidao on January 25, 2012 16:07:29    Last update: January 25, 2012 16:07:29
A JSON response is auto-magically returned when you add the @ResponseBody annotation to the return value of a @RequestMapping annotated method: import org.springframework.stereotype.Controller; ... For magic to happen, you must: Add annotation-driven to the org.springframework.web.servlet.DispatcherServlet config xml: <?xml version="1.0" encoding="UTF-8"?> <beans x... Put Jackson jar files on CLASSPATH (i.e., under WEB-INF/lib ), which includes jackson-core-asl-1.6.4.jar and jackson-mapper-asl-1.6.4.jar .
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 Fang on November 10, 2011 13:19:13    Last update: December 01, 2011 19:10:43
You can add custom implicit variables to JSF pages by using a custom EL resolver, in two simple steps: Write an ELResolver class to resolve the variable Add the ELResolver to faces-config.xml Starting from the Maven Hello World example: Add faces API and EL dependencies to pom.xml : <dependencies> <dependency> <groupId>o... Add a simple greeter class ( src/main/java/com/example/Greeter.java ): package com.example; public class Greeter {... Add our custom EL resolver ( src/main/java/com/example/ELResolver.java ): package com.example; import java.util.Itera... Add the custom EL resolver to src/main/resources/META-INF/faces-config.xml <?xml version="1.0" encoding="UTF-8"?> <faces-c... Build JAR with mvn package Drop the JAR into WEB-INF/lib of a webapp and test the new EL with: <h:outputText value="#{Greeter.sayHi('Mike')}"/> Fixed: the setValue method used to throw an exception, which is wrong. @Override public void setValue(ELContext ctx, O......
Created by Fang on November 22, 2011 10:40:16    Last update: November 22, 2011 10:40:16
This is an example that uses tag handler, UI component and renderer together to support a custom taglib. The main purpose is to show how these components play together. The tag renders <ui:param name="extra" value="el interpreted"/> ... as <h3>my:foreach</h3> <ul class="css class" extra... These are the files: The tag handler ( src/main/java/com/example/ForeachTagHandler.java ): package com.example; import java.util.Map; ... The UI component ( src/main/java/com/example/UIForeach.java ): package com.example; import java.io.IOExcep... The renderer ( src/main/java/com/example/ForeachRenderer.java ): package com.example; import java.io.IOExcep... Faces config ( src/main/resources/META-INF/faces-config.xml ): <?xml version="1.0" encoding="UTF-8"?> <faces-c... Taglib config ( src/main/resources/META-INF/foreach.taglib.xml ): <?xml version="1.0" encoding="UTF-8"?> <facelet...
Created by Fang on November 08, 2011 20:55:00    Last update: November 21, 2011 18:19:44
In the simple taglib example , I used a tag handler class to implement a taglib. This is an example to implement a taglib with a UI component. The purpose is to use a custom tag to split a string and print each part in a separate paragraph, i.e., print <p>john</p> <p>steve</p> <p>mike</p> with custom tag <my:foreach> : <my:foreach var="who" value="john steve mike"> ... These are the files: pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0"... src/main/java/com/example/UIForeash.java : package com.example; import java.io.IOExcep... src/main/resources/META-INF/faces-config.xml : <?xml version="1.0" encoding="UTF-8"?> <faces-c... src/main/resources/META-INF/foreach.taglib.xml : <?xml version="1.0" encoding="UTF-8"?> <facelet... How to use: Put the JAR file generated by the above project in the WEB-INF/lib folder of the web app. If the web app is a Maven project, just add the taglib project as a dependency:...
Created by Fang on November 10, 2011 09:26:12    Last update: November 10, 2011 09:26:12
Syntax highlighted XML schema for JSF 2.0 Application Configuration Resource File ( faces-config.xml ). Almost 3000 lines! <?xml version="1.0" encoding="UTF-8"?> <xsd:sch...
Created by Fang on November 02, 2011 16:40:10    Last update: November 02, 2011 16:40:10
Facelet taglib schema from JavaServer Faces Spec 2.0: <xsd:schema targetNamespace="http://java.sun.com/x...
Created by alfa on May 27, 2011 11:19:29    Last update: May 31, 2011 07:56:26
This is a utility to convert a string value to one of the primitive type values. It is useful in Java reflection code where the value comes in as a string (e.g., from XML parsing), and the type of the value cannot be decided until runtime. import java.util.*; import java.lang.reflect.*;... Note: This method can be extended to convert string to more complex types by writing a converter for the destination type. For example, to convert string to date: public class DateConverter { public static ... Usage: Date d = (Date) ConvertUtil.convert("10/12/2010", ...
Previous  1 2 Next