1 2 Previous Next 29 Replies Latest reply on Mar 19, 2009 7:59 PM by Nick Belaevski

    NEW FEATURE: Script and Style files loading strategy

    Sergey Smirnov Master

      Since RichFaces 3.1.3, you can manage how the RichFaces script and style files will be loaded in your application.

      Before, the version 3.1.3, RichFaces loaded styles and script on demand. I.e. the files are loaded only they are required on the particular page. This approach has benefits and drawbacks.
      For example: If you have a small number of components on the page, loading only the required ones allows to save the traffic and total time of files loading. This is a benefit.
      However, if you use a lot of components of the same page, browser sends separate requests for each of the file and, then, after each file is received, spends time for interpretation of it . Even all script and styles files are cached, it might be a resource-consuming operation (Especially, for Internet Explorer).


      The following declaration in your web.xml allows to load the integrated script files.


      Look at the Browser's DOM tree of any page of the latest (3.13) richfaces-demo. For example,

      You can see that the head section of the page contains references to only two script files: framework.pack.js.jsf and ui.pack.js.jsf. Those are the scripts for framework and components (ui).

      Unless user turn off the cache manually or you turn it off in the web.xml, those two files will be cached and used along the whole application.

      Both files are compressed and have size about 270Kb each.

      Note: Make sure you do not have the script compression on. Otherwise, the double compressing causes the incorrect javascript as a result. The compression is turned on by default. So, if you use LoadScriptStrategy ALL, turn the compression off like it shown in the code snippet above

      If you do not declare the org.richfaces.LoadScriptStrategy in the web.xml, it equals to:


      The classical on-demand strategy is used. If you look at the head section of the same application, but uses the default strategy, you can see the difference in number of files.

      The third possible value is NONE. You have no a special reason to use it unless you obtain the newest (or modified) version of the script and want to include it manually in the page header.


      Similar to the script loading strategy described above. The following declaration allows to load only one integrated style sheet file.

      The integrated style sheet contains style for all shipped components. The skinability feature still works.

      The DEFAULT value is a classical on-demand variant.

      The NONE stops loading the styles at all. This is a special gift for people who still afraids the skinability feature of RichFaces.

      The earlier introduced plain skin resets all color and font parameters to null. The NONE value for org.richfaces.LoadStyleStrategy does even more - No predefined styles for RichFaces at all. The look-n-feel is in your hands on 100%.

        1 2 Previous Next