Recent Notes

Displaying keyword search results 1 - 10
Created by Dr. Xi on March 07, 2013 20:26:23    Last update: March 07, 2013 20:26:23
Create a jax-ws web service with Spring, Apache CXF and Maven. Create the pom.xml : <project xmlns=""... Create the web service interface ( src/main/java/jaxws/ ): package jaxws; import javax.jws.WebService;... Implement the web service ( src/main/java/jaxws/ ): package jaxws; import javax.jws.WebService;... Create src/main/webapp/WEB-INF/cxf-servlet.xml : <?xml version="1.0" encoding="UTF-8"?> <beans x... Register the CXF servlet in src/main/webapp/WEB-INF/web.xml : <?xml version="1.0" encoding="UTF-8"?> <web-app... Build: mvn package The resulting WAR file can be deployed to any servlet container (for example, Tomcat).
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
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=""... src/main/java/com/example/ : package com.example; import 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 03, 2011 19:47:38    Last update: November 08, 2011 20:24:47
This is a step-by-step example to create a really simple facelet taglib (in JSF 2 with Maven). Create a simple Maven project with: mvn archetype:create -DgroupId=com.example -Dartif... Three files are created as a result: pom.xml src/main/java/com/example/ src/test/java/com/example/ This project should be able to build with: mvn package Add facelet API dependencies to pom.xml : <project xmlns=" The compiler plugin section is optional. Remove src/main/java/com/example/ , create a new Java class as the facelet Tag Handler ( ): package com.example; import This tag handler simply prints a "Hello" message. Create facelet tag declaration file src/main/resources/META-INF/hello.taglib.xml : <?xml version="1.0" encoding="UTF-8"?> <facelet... Build the JAR with mvn clean package Optionally, install it to the local repository: mvn install To use the taglib, simply drop the...
Created by Fang on October 28, 2011 13:49:40    Last update: October 30, 2011 19:23:25
This is a simple example to demonstrate the templating power of JSF facelets. If you've used struts tiles before, you'll recognize the simplicity of templating with facelets. I've stripped out everything else except the pages themselves, just to put our focus on facelets. This is a Maven based project, and you need Tomcat (or any servlet container) to run the resulting webapp. To begin with this is the list of files: ./pom.xml ./src/main/webapp/home.xhtml ./src... I left faces-config.xml in there for completeness sake, it may not be needed. The Maven POM ( pom.xml ): <?xml version="1.0" encoding="UTF-8"?> <project... Web app configuration ( WEB-INF/web.xml ): <?xml version="1.0" encoding="UTF-8"?> <web-app... Empty WEB-INF/faces-config.xml : <?xml version="1.0" encoding="UTF-8"?> <!-- Thi... index.jsp is simply a redirect to home.jsf : <% response.sendRedirect("home.jsf"); %>...
Created by freyo on June 30, 2011 12:36:26    Last update: July 01, 2011 09:43:54
Code public void install(View view) { String url = ... Screenshots: Logcat: D/InstallApp( 338): install: file:///sdcard/GetAp... Using http://... as the URI for the APK does not work. Android fails to find a handler for the intent (logcat): No Activity found to handle Intent { act=android.i... Therefore, download the APK to sdcard then fire the Intent.
Created by Dr. Xi on June 16, 2011 14:23:44    Last update: June 16, 2011 14:25:04
This example shows how a service implementation can be loaded with a URLClassLoader . The files. : public interface HelloService { public void... : public class HelloServiceImpl implements HelloServ... uses URLClassLoader to load the service implementation: import*; import*; pub... : import*; import*; pub... Create a runnable client jar: C:\>jar -cfe client.jar Test Test.class ServiceFac... Create a service jar: jar -cf service.jar HelloServiceImpl.class Test: C:\>java -jar client.jar Class Loader: Extra Note: : JDK7 added a method URLClassLoader.close() , so that a URLClassLoader can be discarded, and a new one created to load a new implementation.
Created by Dr. Xi on April 26, 2011 21:25:55    Last update: April 27, 2011 11:08:57
The following code validates a web.xml file against the web-app 2.5 schema: // Java XML validation with schema import java.... web.xml used for testing: <?xml version="1.0" encoding="UTF-8"?> <web-ap... According to Java API doc , validation can also be done while parsing by calling setSchema on the parsing factory. However, validation doesn't work for the SAXParserFactory! // Java XML validation with schema import java....
Created by alfa on April 06, 2011 13:23:40    Last update: April 06, 2011 13:23:40
A file can be read as URL with the package. You must provide absolute path after the URI scheme name file:// . package; import*; i...
Previous  1 2 3 Next