3 Replies Latest reply on Jun 19, 2007 7:36 PM by Igor Shabalov

    Struts2 and Richfaces?

    Kevin Lester Newbie

      Has anyone been able to get RichFaces components to work with the latest version of Struts (Struts 2.0)? Struts 2.0 is supposed to work with JSF components according to their documentation, but I have not yet been able to get it to work successfully with RichFaces.

      I was able to easily get Richfaces to work with the Sun RI of JSF, and I was able to get standard JSF components to work in Struts 2.0, but I cannot get RichFaces components to work in Struts 2.0. The error I receive in my test project when I go to a page containing a RichFaces component is:

      javax.faces.FacesException: Resources framework is not initialised, check web.xml for Filter configuration
       org.ajax4jsf.framework.resource.ResourceBuilderImpl.getWebXml(ResourceBuilderImpl.java:107)
      


      The ajax4jsf configuration in my web.xml was copied and pasted from my other working demo, so I believe this to be something else other than a simply configuration issue.

      So, does anyone know if RichFaces components will work with Struts 2.0? If so, then I'll post more info on my setup, but if it is known to not work then I'll stop my debugging.

      Thanks

        • 1. Re: Struts2 and Richfaces?
          Igor Shabalov Apprentice

          I think you are the first who try such configuration.
          You really need to figure our workable configuration in web.xml. Try to move stuff around, sometimes the right sequence of definitions actually matters.

          • 2. Re: Struts2 and Richfaces?
            Kevin Lester Newbie

            Got it working. I had to switch the ajax4jsf filter mapping to be based off a URL rather than the Faces servlet. My updated web.xml is below:

            <?xml version="1.0"?>
             <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
            
             <display-name>Struts2-JSF</display-name>
            
            <!-- Context Parameters -->
            
             <context-param>
             <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
             <param-value>server</param-value>
             </context-param>
            
             <context-param>
             <param-name>org.ajax4jsf.SKIN</param-name>
             <param-value>blueSky</param-value>
             </context-param>
            
            <!-- End Context Parameters -->
            
            <!-- Filter definitions -->
            
             <filter>
             <display-name>Ajax4jsf Filter</display-name>
             <filter-name>ajax4jsf</filter-name>
             <filter-class>org.ajax4jsf.Filter</filter-class>
             </filter>
             <filter-mapping>
             <filter-name>ajax4jsf</filter-name>
             <url-pattern>*.action</url-pattern>
             <dispatcher>REQUEST</dispatcher>
             <dispatcher>FORWARD</dispatcher>
             <dispatcher>INCLUDE</dispatcher>
             </filter-mapping>
            
             <!-- Start Struts Filter -->
             <filter>
             <filter-name>struts2</filter-name>
             <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
             </filter>
            
             <filter-mapping>
             <filter-name>struts2</filter-name>
             <url-pattern>/*</url-pattern>
             </filter-mapping>
             <!-- End Struts Filter -->
            
            <!-- End Filter definitions -->
            
             <listener>
             <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
             </listener>
            
             <!-- Faces Servlet -->
             <servlet>
             <servlet-name>Faces Servlet</servlet-name>
             <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
             <load-on-startup>1</load-on-startup>
             </servlet>
            
             <!-- Faces Servlet Mapping -->
             <servlet-mapping>
             <servlet-name>Faces Servlet</servlet-name>
             <url-pattern>*.action</url-pattern>
             </servlet-mapping>
            
             </web-app>


            The important change to note above is the line :
            <url-pattern>*.action</url-pattern>
            in the ajax4jsf filter mapping. This is in lieu of the usual
            <servlet-name>Faces Servlet</servlet-name>


            • 3. Re: Struts2 and Richfaces?
              Igor Shabalov Apprentice

              congratulations!