RichFaces 3.3.3 with JSF 2.0 working example

robinmag picture robinmag · Aug 14, 2010 · Viewed 15.4k times · Source

I'm very new to JSF and i'm looking for a pure configuration of JSF 2.0 with RichFaces 3.3.3.Final. The documentation on JBoss website is for JSF 1.2. I also find this jboss article but the sample application has a lot of configurations.

If you have successfully made RichFaces and JSF 2 work, please share you config. Thank you.

Answer

mohamida picture mohamida · Aug 25, 2010

You have to add the latest facelets, richfaces 3.3.3 and jsf 2.x libraries. this is my web.xml config i'm using for my project:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Production</param-value>
    </context-param>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <context-param>
        <param-name>javax.faces.DISABLE_FACELET_JSF_VIEWHANDLER</param-name>
        <param-value>true</param-value>
    </context-param>

    <!--Configuration for Richfaces-->
    <filter>
        <display-name>RichFaces Filter</display-name>
        <filter-name>richfaces</filter-name>
        <filter-class>org.ajax4jsf.Filter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>richfaces</filter-name>
        <servlet-name>Faces Servlet</servlet-name>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>INCLUDE</dispatcher>
    </filter-mapping>
    <!--End of the configuration part for Richfaces-->

    <!--Configuration for Facelets-->
    <context-param>
        <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
        <param-value>.jsp</param-value>
    </context-param>
    <context-param>
        <param-name>facelets.RECREATE_VALUE_EXPRESSION_ON_BUILD_BEFORE_RESTORE</param-name>
        <param-value>false</param-value>
    </context-param>
    <context-param>
        <param-name>facelets.VIEW_MAPPINGS</param-name>
        <param-value>*.xhtml</param-value>
    </context-param>
    <context-param>
        <param-name>facelets.SKIP_COMMENTS</param-name>
        <param-value>true</param-value>
    </context-param>
    <!--End of the configuration part for Facelets-->


    <welcome-file-list>
        <welcome-file>faces/index.jsp</welcome-file>
    </welcome-file-list>


</web-app>

and this is what you can find on my library: standard.jar (for JSTL)

jstl.jar (for JSTL)

jsf-facelets.jar (Facelets 1. 1. 15)

richfaces-api-3.3.3.Final.jar

richfaces-impl-jsf2-3.3. 3.Final.jar

richfaces-ui-3.3.3.Final.jar

commons-beanutils-1.8.3.jar

commons-collections-3.2. 1.jar

commons-digester-2.0.jar

commons-logging-1.1.1.jar

jsf-api.jar (for JSF2)

jsf-impl.jar(for JSF2)

HTH.