10 Replies Latest reply on Sep 28, 2010 1:48 PM by ozbluesky

    Richface and Facelets Template work together

    ozbluesky

      Hi,

       

       

      I'm trying out facelets templates in Netbewn 6.9.1. Code works fine as:

      template.xhtml:

      ...

      <div id="top">
      <ui:insert name="top">
      <ui:include src="header.xhtml" />
      </ui:insert>
      </div>

       

      greeting.xhtml

      ...

      <ui:composition template="./template.xhtml">
      <ui:define name="title">
      Greeting
      </ui:define>
      </ui:composition>

       

      However, as soon as I added Richfaces libraries into the project, and modified web.xml as developer guide, the facelets template stopped working. I haven't include richfaces tag in xhtml files yet.

       

      Is it possible to have facelets template work with Richfaces?

       

       

      Thanks,

      River

        • 1. Re: Richface and Facelets Template work together
          ozbluesky

          Not getting any answer here, does this mean it's not possible to use template with Richfaces?

          • 2. Re: Richface and Facelets Template work together
            volothamp

            Yes it's possible. Would you please post the web.xml file?

            • 3. Re: Richface and Facelets Template work together
              kanal

              River Zhu wrote:

               

              (...) does this mean it's not possible to use template with Richfaces?

              It is possible to use them together.

              Right now I'm using facelets and richfaces.

              Maybe you downloaded wrong version of richfaces. You should use version 4.x for JSF2 (which uses facelets instead of JSP pages like it was in JSF 1.2 and lower).

              • 4. Re: Richface and Facelets Template work together
                amarkhel

                I guess problem in wrong configuration of web.xml, something like wrong view-handler declaration. Put your web.xml please

                • 5. Re: Richface and Facelets Template work together
                  ozbluesky

                  Thanks for responding, this will definitely help me. I tried on both JSF1.2 and JSF2.0, both are not working:

                   

                  For JSF1.2, jar files I included are:

                  1. richfaces-api-3.3.3.Final.jar
                  2. richfaces-impl-3.3.3.Final.jar
                  3. richfaces-ui-3.3.3.Final.jar
                  4. commons-beanutils-1.7.0.jar
                  5. commons-collections-3.2.1.jar
                  6. commons-digester-1.8.jar
                  7. commons-logging-1.0.4.jar
                  8. jhighlight-1.0.jar

                   

                  For JSF2, I included same set of files except replace richfaces-impl-3.3.3.Final.jar with richfaces-impl-jsf2-3.3.3.Final.jar

                   

                   

                  Here is web.xml

                   

                  <?xml version="1.0" encoding="UTF-8"?>
                  <web-app version="3.0" 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_3_0.xsd">
                      <context-param>
                          <param-name>javax.faces.PROJECT_STAGE</param-name>
                          <param-value>Development</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>
                      <session-config>
                          <session-timeout>
                              30
                          </session-timeout>
                      </session-config>
                      <welcome-file-list>
                          <welcome-file>faces/greeting.xhtml</welcome-file>
                      </welcome-file-list>

                  <!-- Template stopped working once I added below part -- >

                  <!-- Plugging the "Blue Sky" skin into the project -->
                      <context-param>
                          <param-name>org.richfaces.SKIN</param-name>
                          <param-value>blueSky</param-value>
                      </context-param>
                  <!-- Making the RichFaces skin spread to standard HTML controls -->
                      <context-param>
                          <param-name>org.richfaces.CONTROL_SKINNING</param-name>
                          <param-value>enable</param-value>
                      </context-param>

                  <!-- Defining and mapping the RichFaces filter -->
                      <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>
                  <context-param>
                       <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
                       <param-value>com.sun.facelets.FaceletViewHandler</param-value>
                  </context-param>

                  </web-app>

                  • 6. Re: Richface and Facelets Template work together
                    nbelaevski

                    Hi River,

                     

                    Just to clarify: are Facelets 1.1.x (.jar file) present in your JSF 1.2 & 2.0 configurations?

                    • 7. Re: Richface and Facelets Template work together
                      nbelaevski

                      Paul,

                       

                      RF 3.3.3 should work with JSF 2 too (see wiki article for more information).

                      • 8. Re: Richface and Facelets Template work together
                        ozbluesky

                        Initially I didn't have Facelet plug-in in my NetBeanm 6.9.1. It works as long as RichFaces is not included.

                        Then I installed Netbean Plugin Facelets 1.1.14 (JSF 1.2), and include "JSF 1.2 + Facelets 1.1.14" library, which add org-netbeans-modules-web-facelets010114.jar to libraries, it also works as long as RichFaces is not used.

                         

                        However, as soon as I configure project with RichFaces, neither of them would work.

                         

                        I've seen lots of samples using Facelet, but still not able to make it work for me. My files are attached.

                         

                        Thanks for help

                         

                        • 9. Re: Richface and Facelets Template work together
                          amarkhel

                          Do you have faces-config.xml file in your project?

                           

                          Here example of this file, needed to proper work of facelets:

                           

                          <?xml version='1.0' encoding='UTF-8'?>
                          <faces-config version="1.2"
                          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-facesconfig_1_2.xsd">
                          <application>
                          <locale-config>
                          <default-locale>en</default-locale>
                          <supported-locale>fr</supported-locale>
                          </locale-config>
                          <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
                          </application>

                          • 10. Re: Richface and Facelets Template work together
                            ozbluesky

                            Thanks Andrey, faces-config.xml was not generated by default by Netbean. (for any reason?)

                             

                            I created one using it's default version="2.0", and added <view-handler>. The template starts working for both JSF1.2 and JSF 2.0. It needn't  Facelets 1.1.14 plug-in, which add org-netbeans-modules-web-facelets010114.jar to libraries. (It's an extra step I tried earlier.)

                             

                            faces-config.xml

                            <?xml version='1.0' encoding='UTF-8'?>
                            <faces-config version="2.0"
                                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-facesconfig_2_0.xsd">

                            <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
                            </faces-config>

                             

                            I did more test on JSF 2.0, my findings are:

                             

                            1. I cannot turn off VDL viewhandler as Ilya's artical "RichFaces 3.3.3 and JSF 2.0" by adding following code in web.xml. It make template not working. Will this cause any problem later on?

                            <context-param>
                                 <param-name>javax.faces.DISABLE_FACELET_JSF_VIEWHANDLER</param-name>
                                 <param-value>true</param-value>
                            </context-param>

                             

                            2. It's ok to have following code from Richface developer guide 4.4 facelet support. However, it didn't make a difference. Are they doing same thing?

                            <context-param>
                            <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
                            <param-value>com.sun.facelets.FaceletViewHandler</param-value>
                            </context-param>

                             

                             

                            Regards,

                            River