3 Replies Latest reply on Sep 8, 2010 11:10 AM by igor regis

    Load Richfaces Sctipts and Styles from a centralized place

    Herbert Dowalil Newbie

      hi!

       

      we  have dozens of richfaces applications, and a lot of users who use them  with slow mobile connections. the start of the different applications is  always slow, because all the richfaces .css and .js files are loaded  for every application and not cached by the browser like this one

       

      http://www.whatever.com/svp/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/modalPanel.js.xhtml

       

      other apps load the same file from

       

      http://www.whatever.com/poskfz/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/modalPanel.js.xhtml

       

      can  i somehow tell richfaces to get the global .js and style files from a  resource webapp? so these files are cached once for all the apps (they  are all using rf 3.3.3) like:

       

      http://www.whatever.com/resources/a4j/g/3_3_3.Finalorg/richfaces/renderkit/html/scripts/modalPanel.js.xhtml

       

      any help appreciated

       

      thanks in advance

      herbert

        • 1. Re: Load Richfaces Sctipts and Styles from a centralized place
          igor regis Newbie

          HI Hebert, we have the same issue. Richfaces don't provide any option to configure a centralized web context to supply these resources files, so I have made a patch for Richfaces. I was about to post about this patch here in the forums to discuss this change with the community.

           

          You will have the change the org.ajax4jsf.webapp.WebXml class the method:

           

          "public String getFacesResourceURL(FacesContext context, String Url, boolean isGlobal)"

           


          This method returns a "resourceURL" all you have to do is add this kind if code:

           

          resourceURL = MY_CENTRALIZED_CONTEXT + resourceURL.substring(resourceURL.indexOf(RESOURCE_URI_PREFIX));

           

          where MY_CENTRALIZED_CONTEXT is a constant with a value like that: "/myContext/"

           


          You can initialize this constant with a context param, like the others that a4j use, or just code it.

           


          So, what do you think about we open a JIRA issue requesting this improvement to Richfaces?

           


          Ps.: I have patched Richfaces 3.3.1 (this is the release we are using)

           

                 The class org.ajax4jsf.webapp.WebXml is placed on richfaces-impl file.

          • 2. Re: Load Richfaces Sctipts and Styles from a centralized place
            Herbert Dowalil Newbie

            hi igor!

             

            yes, great. i also already had a look at this class and was considering changing it :-)

            i just thought that there must be a better solution

             

            so thanks for your hint, i agree that we should add this as a feature request for RichFaces!

             

            will try it out in the next couple of days / weeks depending on our workload

             

            regards,

            herbert

            • 3. Re: Load Richfaces Sctipts and Styles from a centralized place
              igor regis Newbie

              Herbert,


              There is another issue that may affect you, the Richfaces don't set the "public" value on Cache-control header tag, so if you are running your applications under https, none of theses resources will be cached on disk.

               

              For more details, I am discussing this on this thread:
              https://community.jboss.org/thread/150732?tstart=0