Notes by Fang
Displaying notes 91 - 100
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 November 03, 2011 21:11:55
Last update: November 03, 2011 21:11:55
Facelet tag library descriptors can be specified in one of two ways:
In web.xml , as <context-param> :
<context-param>
<param-name>javax.faces...
where javax.faces.FACELETS_LIBRARIES is interpreted as a semicolon ( ; ) separated list of paths, starting with "/" (without quotes). Each entry in the list is a path relative to the web application root, and is interpreted as a facelet XML tag library descriptor.
The parameter facelets.LIBRARIES is an alias to javax.faces.FACELETS_LIBRARIES for backwards compatibility reasons.
Via auto-discovery, by placing the XML tag library descriptor within a jar on the web application classpath (for example, under the folder WEB-INF/lib ). The file should have a name suffix .taglib.xml , and be placed in the META-INF folder of the JAR file.
Created by Fang on November 03, 2011 14:56:59
Last update: November 03, 2011 14:56:59
I want to add my own file to the META-INF folder of maven generated JAR. This is how:
Create folder resources/META-INF under src/main (if it doesn't exist already).
Copy the file to resources/META-INF .
Maven package will automatically add the file to the finished JAR.
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 November 01, 2011 15:14:41
Last update: November 01, 2011 15:14:41
Got this error when my XHTML file contained the white space entity .
It turns out that there are only five predefined entities in XML, isn't among the five.
Solution: replace with   .
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: