JSF+Facelets+Richfaces Installation-Guide: Libraries
JSF+Facelets+Richfaces Installation-Guide: Libraries
Introduction
Installing facelets together with richfaces is very simple. I used to develope web applications
with JSF and its libraries like richfaces, Icefaces and so on. But I felt, my application have
achieved a greater landmark only after implementing facelets. The reason is, facelets contains
obliging features like templating(Similarly like struts), Composition components(Reuse can be
achieved), also resolves the mismatch between JSF and JSP technologies(Eg: <jsp:param> tag
cannot be used in JSF while using <jsp:include> tag) and so on. This article explains the
installation of Richfaces and facelets with JSF.
Prerequisites
IDE – Netbeans 6.x or Eclipse(Now Netbeans 6.7 provides the feature for creating
facelets projects)
Tomcat 6.x or Glassfish
JDK 1.5 and above
Installing facelets can be accomplished by four steps in a web application project. If you are the
one who use Netbeans 6.7 IDE which provides the features for creating facelet projects kindly
skip the below step1 and step3 and just add the richfaces jars specified in the libraries and
configure richfaces in web.xml. Others kindly follow the below steps,
Step – 1
In step1, download and ensure that your projects WEB-INF/lib directory contains the below jar
files.
Libraries
commons-beanutils.jar
commons-collections.jar
commons-digester.jar
commons-logging.jar
el-ri.jar
jhighlight-1.0.jar
jsf-api.jar
jsf-facelets.jar
jsf-impl.jar
jstl.jar
richfaces-api-3.3.1.GA.jar
richfaces-impl-3.3.1.GA.jar
richfaces-ui-3.3.1.GA.jar
Step – 2
Step2 clearly explains how to configure the web.xml for the facelet projects.
web.xml configuration
view source
print?
01 <?xml version="1.0" encoding="UTF-8"?>
02
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
03
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
04
05 <context-param>
06 <param-name>com.sun.faces.verifyObjects</param-name>
07 <param-value>true</param-value>
08 </context-param>
09 <context-param>
10 <param-name>com.sun.faces.validateXml</param-name>
11 <param-value>true</param-value>
12 </context-param>
13 <context-param>
14 <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
15 <param-value>.xhtml</param-value>
16 </context-param>
17 <context-param>
18 <param-name>facelets.DEVELOPMENT</param-name>
19 <param-value>false</param-value>
20 </context-param>
21 <context-param>
22 <param-name>facelets.SKIP_COMMENTS</param-name>
23 <param-value>true</param-value>
24 </context-param>
25 <!-- Richfaces Configuration-->
26 <context-param>
27 <param-name>org.richfaces.SKIN</param-name>
28 <param-value>wine</param-value>
29 </context-param>
30 <context-param>
31 <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
32 <param-value>com.sun.facelets.FaceletViewHandler</param-value>
33 </context-param>
34 <filter>
35 <display-name>RichFaces Filter</display-name>
36 <filter-name>richfaces</filter-name>
37 <filter-class>org.ajax4jsf.Filter</filter-class>
38 </filter>
39 <filter-mapping>
40 <filter-name>richfaces</filter-name>
41 <servlet-name>Faces Servlet</servlet-name>
42 <dispatcher>REQUEST</dispatcher>
43 <dispatcher>FORWARD</dispatcher>
44 <dispatcher>INCLUDE</dispatcher>
45 </filter-mapping>
46 <servlet>
47 <servlet-name>Faces Servlet</servlet-name>
48 <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
49 <load-on-startup>1</load-on-startup>
50 </servlet>
51 <servlet-mapping>
52 <servlet-name>Faces Servlet</servlet-name>
53 <url-pattern>*.jsf</url-pattern>
54 </servlet-mapping>
55 <session-config>
56 <session-timeout>
57 30
58 </session-timeout>
59 </session-config>
60 <welcome-file-list>
61 <welcome-file>index.jsp</welcome-file>
62 </welcome-file-list>
63 </web-app>
Step – 3
Step3 explains the faces-config configurations.
faces-config configuration
view source
print?
1 <application>
2 <view-handler>
3 com.sun.facelets.FaceletViewHandler
4 </view-handler>
5 </application>
Now you have completed the installation successfully and next you need create web pages in
xhtml documents and you should specify the taglibs in XML namespaces instead of JSP taglibs.
Step – 4
Create a xhtml document and your web page should contain the taglibs as stated in
sample.xhtml, so that you can use the rich faces components together with facelets.
sample.xhtml
view source
print?
01 <?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
02
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
03 <html xmlns="http://www.w3.org/1999/xhtml"
04 xmlns:ui="http://java.sun.com/jsf/facelets"
05 xmlns:f="http://java.sun.com/jsf/core"
06 xmlns:h="http://java.sun.com/jsf/html"
07 xmlns:a4j="http://richfaces.org/a4j"
08 xmlns:rich="http://richfaces.org/rich">
09 <body>
10 <h:form method="post">
11 <rich:panel>
12 <h:outputText value="Sample Text"></h:outputText>
13 </rich:panel>
14 </h:form>
15 </body>
16 </html>
Thatsall folks. I hope this article clearly explains the installation of Facelets and Richfaces with
JSF. Some may say, this article is only about installation, but I want to get in to the action!!.
Dont worry just follow the link Layouting and Dynamic include in Facelets , which will help you
to construct templates and dynamic include using Facelets. If you find this article is quite
useful, Dont forget to share with me by your valuable comments. Have a joyous code day.