Installing Facelets under JSF 1.2 (or JSF 1.1)

This recipe lists the main steps for installing Facelets under JSF 1.2. For JSF 2.0, Facelets is bundled, therefore no installation is needed.

Getting ready

To start with, you need to download Facelets from https://facelets.dev.java.net/. It is recommended to download the latest stable release.

How to do it...

Once you have downloaded the Facelets distribution, you can install it under your project by following the given steps:

  • Unzip the Facelets distribution under your favorite folder.
  • Copy the Facelets JARs under your project /WEB-INF/lib folder.
  • Add the Facelets init parameter(s) to the web.xml file, as follows:
    <context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>.xhtml</param-value>
    </context-param>
    

Add the FaceletViewHandler to the faces-config.xml file, as follows:

<application>
<locale-config>
<default-locale>en</default-locale>
</locale-config>
<view-handler>com.sun.facelets.FaceletViewHandler</view-handler> </application>

Done! Now, you are ready to explore Facelets in your JSF projects.

Note

A JSF ViewHandler consists a plugin that handles the Render Response and Restore View phases of the JSF request-process life cycle.

There's more...

Do not forget that for JSF 2.0, Facelets is already bundled and configured, therefore you can use it out of the box.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset