Home > Articles > Programming > Java

  • Print
  • + Share This
This chapter is from the book

3.3 Add Facelets and Seam UI Support

To support the Facelets and Seam UI frameworks, you must first bundle the necessary library JAR files in the application. Three JAR files go into the app.war archive's WEB-INF/lib directory because they contain tag definitions. Facelets requires the jsf-facelets.jar file; Seam needs the jboss-seam-ui.jar and jboss-seam-debug.jar files. An additional JAR file, jboss-el.jar, goes into the EAR file mywebapp.ear to support the JSF Expression Language (EL) in both the web module (app.war) and the EJB3 module (app.jar).

|+ app.war
   |+ web pages
   |+ WEB-INF
      |+ web.xml
      |+ faces-config.xml
      |+ other config files
      |+ lib
         |+ jsf-facelets.jar
         |+ jboss-seam-ui.jar
         |+ jboss-seam-debug.jar
|+ app.jar
|+ lib
   |+ jboss-el.jar
   |+ jboss-seam.jar
   |+ application.xml
   |+ jboss-app.xml

To use Facelets and Seam's enhancements to JSF EL, you need to load a special view handler in the faces-config.xml file, which is located in the WEB-INF directory in the app.war (or in the resources/WEB-INF directory in the project source). The view handler renders HTML web pages from Facelets template and pages. This is the relevant snippet from the faces-config.xml file:

  ... ...

In a Facelets application, we typically use the .xhtml filename suffix for web pages since they are now XHTML files, not JSP pages. We have to tell the JSF runtime about this change in the web.xml file (in the same directory as the faces-config.xml file):

  ... ...

Finally, let's set up the Seam filter and resource servlet in the same web.xml file. The SeamFilter provides support for error pages, JSF redirects, and file upload. The Seam resource servlet provides access to images and CSS files in jboss-seam-ui.jar, which are required by Seam UI components. The resource servlet also enables direct JavaScript access to Seam components (Chapter 21).

  ... ...
    <servlet-name>Seam Resource Servlet</servlet-name>

    <servlet-name>Seam Resource Servlet</servlet-name>

    <filter-name>Seam Filter</filter-name>

    <filter-name>Seam Filter</filter-name>

  • + Share This
  • 🔖 Save To Your Account