Recent Notes
Displaying keyword search results 91 - 100
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/App.java src/test/java/com/example/AppTest.java This project should be able to build with: mvn package Add facelet API dependencies to pom.xml : <project xmlns="http://maven.apache.org/POM/4.... The compiler plugin section is optional. Remove src/main/java/com/example/App.java , create a new Java class as the facelet Tag Handler ( HelloTagHandler.java ): package com.example; import java.io.IOExcep... 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 November 08, 2011 14:40:57
Last update: November 08, 2011 14:40:57
This error happened when I loaded a JSF page, using Apache MyFaces. From the stack trace it looked like the XML parser failed, but in reality the runtime was not able to load the class specified in the handler-class element - a typo in the class name! That's the price you pay for wiring together components with XML!
This was the stack trace:
Caused by: org.xml.sax.SAXException: Error Handlin...
Created by Fang on November 07, 2011 09:41:57
Last update: November 07, 2011 09:42:25
Using JSTL tags in JSF facelets is quite simple: just add the XML namespace for the JSTL tags and use them in the page.
An example of using the <c:if> tag:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Trans...
Created by Fang on November 05, 2011 07:21:14
Last update: November 05, 2011 07:21:14
Generated documentation of JSF 2.1 facelet tags:
http://javaserverfaces.java.net/nonav/docs/2.1/vdldocs/facelets/index.html
Created by Fang on November 04, 2011 14:45:20
Last update: November 04, 2011 19:55:34
To get the values of web.xml context parameters:
from faces context:
facesContext
.getExternalContext()
.getInitP...
from facelets context:
faceletContext
.getFacesContext()
.getExtern...
inside a page:
#{initParam['PARAM_NAME']}
Created by Fang on September 07, 2009 20:44:15
Last update: November 03, 2011 14:43:19
Step 1: Repackage a web app as EAR A Java EE application is a multimodule Maven project. At the very least you'll need to package a WAR and an EAR. To get started, I'll simply re-package the simple webapp as an EAR. Create a directory named javaee-app Copy the webapp from here to javaee-app . Rename struts1app to webapp . Create pom.xml under javaee-app :
<project> <modelVersion>4.0.0</modelVersion>... Create a directory named ear under javaee-app . Create pom.xml under ear : <project> <modelVersion>4.0.0</modelVersion>... Modify pom.xml in the webapp directory so that it looks like this: <project> <modelVersion>4.0.0</modelVersion> ... Build with " mvn package " in the javaee-app directory. You can see that ear-1.0.ear is successfully generated in javaee-app/ear/target . Maven successfully resolves dependencies between the sub-projects....
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 Fang on November 02, 2011 14:40:16
Last update: November 02, 2011 14:40:48
JSTL was built for Java Server Pages (JSPs). With the coming of JSF 2.0, facelets, instead of JSP , is the preferred page rendering technology.
Facelets exposes a subset of the JSTL Core tag library and the entirety of the JSTL Function tag library.
The JSTL tags available in facelets are:
c:set
c:if
c:forEach
c:choose
c:when
c:otherwise
c:catch
Created by Fang on October 31, 2011 21:10:10
Last update: October 31, 2011 21:13:10
In this example I'll add a parameter to a facelets template. The example contains three tabs, each tab points to a different page. The tab control is shared among all pages, therefore, it is put in the template.
Starting from the simple facelet example , make these additions:
Create a new template WEB-INF/templates/tabs.xhtml :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Stric...
Add a page for the about tab ( about.xhtml ):
<?xml version="1.0" encoding="UTF-8"?>
<ui:comp...
Add a page for the news tab ( news.xhtml ):
<?xml version="1.0" encoding="UTF-8"?>
<ui:comp...
Add a page for the partner tab ( partner.xhtml ):
<?xml version="1.0" encoding="UTF-8"?>
<ui:comp...
Build and re-deploy the application. Launch the browser and load page http://localhost:8080/facelet-demo/about.jsf .
This is a screenshot: