9 Replies Latest reply on Apr 30, 2012 10:31 AM by antoine_h

    NONE LoadStrategy for RichFaces in GateIn

    nscavell

      In JBoss Portal you could configure richfaces with the NONE load strategy.  Is there a way to achieve this same behavior in GateIn ?

       

      For example you would include the following in your jboss-portlet.xml file to manually import the richfaces resources:

       

      <script src="/faces/rfRes/org/ajax4jsf/framework.pack.js" type="text/javascript"></script>
      <script src="/faces/rfRes/org/richfaces/ui.pack.js" type="text/javascript"></script>
      <link rel="stylesheet" type="text/css" href="/faces/rfRes/org/richfaces/skin.xcss"/>

       

       

      * EDIT wikimarkup wasn't showing code...

        • 1. Re: NONE LoadStrategy for RichFaces in GateIn
          mwringe

          You can use the doHeader method of the portlet to set what you want added to the html head. This can be use to add those scripts and links to your page.

          • 2. Re: NONE LoadStrategy for RichFaces in GateIn
            nscavell

            Thanks for the reply.  As this wasn't quite the answer I was hoping for, it does accomplish what I need fairly easily.  My main issue was that I could not get the RichFaces resources (javascript, css, etc) to cache appropriately.  This is why I have gone down the LoadStrategy of NONE approach of configuring RichFaces.  I think the ALL LoadStrategy would meet my needs if RichFaces was being properly cached in the portal.  The URL to fetch these resources was a portal page URL request, and not the typical /faces/rfRes/org/ajax4jsf/framework.pack.js as you get with the NONE option.

             

            For example the request to fetch framework.pack.js with the ALL LoadStrategy, I was getting something like:

             

            http://localhost:8080/portal/private/classic/examples/helloworld?portal:componentId=2fcec5c1-cad4-472e-bb2c-4103d52f71e7&portal:type=resource&portal:cacheLevel=PAGE&resourcestate=JBPNS_rO0ABXdbAAVyZlJlcwAAAAEAHk1FVEEtSU5GL3NraW5zL2dlc3RhbmRhcmQueGNzcwAEREFUQQAAAAEAGy9CL2VBRVQwTlR4RFYwLVF4b0FDTVFDWWdfXwAHX19FT0ZfXw**&portal:windowState=normal&portal:portletMode=view

             

            However when changing to NONE strategy and overriding the doHeaders method for my portlets, I started seeing requests like:

             

            http://localhost:8080/portal/faces/rfRes/org/ajax4jsf/framework.pack.js

             

            which was being cached correctly, and taking the default org.ajax4jsf.DEFAULT_EXPIRE value of 86400 (24 hours).

             

            If anyone has had any luck  caching RichFaces with the ALL LoadStrategy please let me know.  I'm using the following technologies:

             

            GateIn 3.0.0.GA

            RichFaces 3.3.3.Final

            PortletBridge 2.0.0.Final

            • 3. Re: NONE LoadStrategy for RichFaces in GateIn
              michaelschuetz

              So, just to get this correctly: ALL LoadStrategy does not work at the moment with GateIn and RichFaces? Could anybody confirm this please? Is there a JIRA issue, already?

               

              Cheers

              Michael

              • 4. Re: NONE LoadStrategy for RichFaces in GateIn
                nscavell

                My issue was not that it didn't work, but I noticed that it was bringing the entire payload of RichFaces over on every request, which if I recall correctly (it's been awhile) was about 1MB.  I'm not sure if it was a configuration issue on my end, but that's what I noticed.  Instead we went with just having an abstract richfaces portlet which performed the doHeaders "stuff".  This was a better solution in the end for us anyways.

                • 5. Re: NONE LoadStrategy for RichFaces in GateIn
                  michaelschuetz

                  Nick, thanks for your reply. That's pretty interesting.

                  Instead we went with just having an abstract richfaces portlet which performed the doHeaders "stuff".  This was a better solution in the end for us anyways.

                  Would love to see code snippets of important parts of your solution.

                   

                  Thanks a lot

                  Michael

                  • 6. Re: NONE LoadStrategy for RichFaces in GateIn
                    michaelschuetz

                    OK, what i did:
                    1) own implementation of GenericFacesPortlet

                     

                     

                     

                    {code}

                    public abstract class MyGenericFacesPortlet extends GenericFacesPortlet {

                        @Override

                         protected void doHeaders(RenderRequest request, RenderResponse response) {
                             super.doHeaders(request, response);

                            Element richfacesCSS = response.createElement("link");

                             richfacesCSS.setAttribute("id", "richfaces");
                             richfacesCSS.setAttribute("type", "text/css");
                             richfacesCSS.setAttribute("rel", "stylesheet");
                             richfacesCSS.setAttribute("href", request.getContextPath() + "/faces/rfRes/org/richfaces/skin.xcss");
                             response.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, richfacesCSS);

                            Element ajax4jsfScript = response.createElement("script");

                             ajax4jsfScript.setAttribute("type", "text/javascript");
                             ajax4jsfScript.setAttribute("src", request.getContextPath() + "/faces/rfRes/org/ajax4jsf/framework.pack.js");
                             response.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, ajax4jsfScript);

                            Element richfacesScript = response.createElement("script");

                             richfacesScript.setAttribute("type", "text/javascript");
                             richfacesScript.setAttribute("src", request.getContextPath() + "/faces/rfRes/org/richfaces/ui.pack.js");
                             response.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, richfacesScript);
                         }
                    }

                     

                    {code}

                     

                     


                    2) using this implementation in portlet.xml

                     

                    3) in portlet.xml, additionally configured:

                     

                     

                    {code}

                    <container-runtime-option>
                                <name>javax.portlet.renderHeaders</name>
                                <value>true</value>
                            </container-runtime-option>

                    {code}

                     

                     

                    4) web.xml

                     

                     

                    {code}

                     

                    <context-param>
                            <param-name>org.richfaces.LoadStyleStrategy</param-name>
                            <param-value>NONE</param-value>
                        </context-param>

                     

                    <context-param>
                             <param-name>org.richfaces.LoadScriptStrategy</param-name>
                             <param-value>NONE</param-value>
                         </context-param>
                        
                         <context-param>
                             <param-name>org.ajax4jsf.RESOURCE_URI_PREFIX</param-name>
                             <param-value>rfRes</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>
                        <servlet-mapping>
                            <servlet-name>Faces Servlet</servlet-name>
                            <url-pattern>*.seam</url-pattern>
                        </servlet-mapping>

                     

                    {code}

                     

                     

                     
                           
                    5) I got 404 error_ can't find http://localhost:8080/my-application/faces/rfRes/org/ajax4jsf/framework.pack.js

                    I am not able to invoke this resource manually.

                     

                    I did follow guidelines defined here http://docs.redhat.com/docs/en-US/JBoss_Enterprise_Portal_Platform/5.0/html/Reference_Guide/sect-Reference_Guide-Bridge_Configuration-RichFaces_Setup_and_Configuration_Options.html and here http://community.jboss.org/wiki/jQueryportlet.

                     

                     

                    Anybody an idea what's wrong?

                     

                    Thanks a lot
                    Michael

                    • 7. Re: NONE LoadStrategy for RichFaces in GateIn
                      nscavell

                      Do you have the ajax4jsf filter defined in your web.xml ?

                      • 8. Re: NONE LoadStrategy for RichFaces in GateIn
                        michaelschuetz

                        Hi Nick,

                         

                        thanks a lot for your reply.

                         

                        Do you have the ajax4jsf filter defined in your web.xml ?

                         

                        Regarding to documentation, this is not required: http://docs.redhat.com/docs/en-US/JBoss_Enterprise_Portal_Platform/5.0/html/Reference_Guide/sect-Reference_Guide-Bridge_Configuration-RichFaces_Setup_and_Configuration_Options.html

                         

                        I did try this anyway - and you're right (-:
                        In web.xml, Ajax4jsf-Filter needs to be configured - and not SeamResourceServlet and SeamFilter.

                         

                        Caching works as expected now.

                         


                        Thanks again
                        Cheers
                        Michael

                        • 9. Re: NONE LoadStrategy for RichFaces in GateIn
                          antoine_h

                          it was bringing the entire payload of RichFaces over on every request, which if I recall correctly (it's been awhile) was about 1MB

                          I am bumping in the same problem.

                          no cache of the RichFaces scripts and CSS...

                           

                          Thank's a lot for the answers and explainations.

                          Antoine

                          JBoss Portal and GateIn, JSF, Richfaces, J2EE.

                          Presta-Expert, le portail pour trouver un expert.