3 Replies Latest reply on Jan 23, 2008 11:10 AM by ilya_shaikovsky

    Richfaces + Facelets

      Calling for advice here.

      I`m trying to add facelets to richfaces-enabled application, and cant get it to work right.

      I added the following to the web.xml:

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


      when i add

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


      to my application definition in faces-config.xml and put the 1.1.13 jsf-facelets.jar to my libs, everything breaks and things just stop working for me.

      if i do not though, templates are working but in a wrong way.

      suppose i have a aj4:include that inserts "current page" portion into my main panel. When i replace my working .jspx with one that uses template following can be observed.

      1) text outside of <ui:composition>...</ui:composition> gets rendered.
      2) templated portion of mainpanel gets rendered every other try.
      3) templated portion of mainpanel gets its layout messed up, like:

      <template.jspx>

      
      ...
      
      <h:panelGrid columns="2" style="width: 100%;" styleClass="main" columnClasses="commonCell">
      <ui:insert name="part1">Default text</ui:insert>
      <ui:insert name="part2">Default text</ui:insert>
      </h:panelGrid>
      
      ...
      
      



      <page.jspx>

      <jsp:root version="2.0"
       xmlns:jsp="http://java.sun.com/JSP/Page"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:a4j="http://richfaces.org/a4j"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:rich="http://richfaces.org/rich">
      <ui:composition template="/res/xhtml/template.jspx">
       <ui:define name="part1">
      
      ....
      
       </ui:define>
      
       <ui:define name="part2">
      
      ....
      
       </ui:define>
      
      
      </ui:composition>
      </jsp:root>


      part2 is rendered below part1, and not next to it (as it correctly does in non-templated version of .jspx)

      Any comments, please?

        • 1. Re: Richfaces + Facelets
          ilya_shaikovsky

          At first you need to define only one facelets view handler. You can't define both in faces confing and web.xml.

          To achieve layout you need just move panelGrid to template ;)

           <h:panelGrid columns="2">
           <ui:insert name="body"></ui:insert>
           <ui:insert name="body2"></ui:insert>
           </h:panelGrid>
          

          Works as you need for me.

          • 2. Re: Richfaces + Facelets

             

            "ilya_shaikovsky" wrote:
            At first you need to define only one facelets view handler. You can't define both in faces confing and web.xml.

            yeah, figured that out in the documentation.

            "ilya_shaikovsky" wrote:

            To achieve layout you need just move panelGrid to template ;)

             <h:panelGrid columns="2">
             <ui:insert name="body"></ui:insert>
             <ui:insert name="body2"></ui:insert>
             </h:panelGrid>
            

            Works as you need for me.


            well my h:panelGrid is defined in the template already as i mentioned above, and it doesnt work for me. could it be because of <jsp:root> element declaration in <page.jspx> ?

            guess i`ll have to dig a bit more.



            • 3. Re: Richfaces + Facelets
              ilya_shaikovsky

              sorry.. I've looked wrong snippet.. but as I mentioned the grid in template helps me..