Home / Articles / Optimizing JSF Richfaces Applications

Optimizing JSF Richfaces Applications

JSF RIA based applications with richfaces comes with very common, mature and stable choice. Infact, richfaces is mature enough technology for implementing AJAX, rich user interfaces easily in JSF. I am sharing some of the common best practices for optimizing JSF richfaces application. 

<context-param>

        <param-name>org.ajax4jsf.COMPRESS_SCRIPT</param-name>
        <param-value>true</param-value>

</context-param>

This config will enforce the container to compress all the richfaces resources including images, stylesheets, javascript to be compressed before sending to client. It will make significant reduced load time.

<filter>
<filter-name>richfaces</filter-name>

<display-name>RichFaces Filter</display-name>

<filter-class>org.ajax4jsf.Filter</filter-class>

<init-param> <param-name>forceparser</param-name>

<param-value>false</param-value>

</init-param>

</filter> 

This can be minimized by setting the forceparser setting to false. In that case only AJAX responses will be ‘tidied’. In the other case all JSF responses are ‘tidied’. That is because the filter is mapped on the Faces servlet: This can be used for partial page rendering.

 

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

This configuration will make sure that all style related files should be loaded at client side at once on first request when richfaces application is accessed. 

<context-param>
<param-name>org.richfaces.LoadScriptStrategy</param-name>
<param-value>all</param-value>
</context-param>

This JSF richfaces optimization tip will make sure that all the javascript, files & libraries assosiated with richfaces should be downloaded at client side at the time of first request from client.

<filter>
<display-name>RichFaces Filter</display-name>
<filter-name>richfaces</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
<init-param> <param-name>enable-cache</param-name>
<param-value>true</param-value> </init-param>
</filter>

This JSF richfaces optimization tip to enable cache richfaces components at client side and boost up significant performance hit.

 

Richfaces has a few parsers onboard. The default one is based on Tidy, but it is quite slow. The Neko parser is faster and can be used by setting the following context-param’s:
<context-param>
        <param-name>org.ajax4jsf.xmlparser.ORDER</param-name>
        <param-value>NEKO</param-value>
    </context-param>

    <context-param>
        <param-name>org.ajax4jsf.xmlparser.NEKO</param-name>
        <param-value>.*..*</param-value>
    </context-param>

Here we say we only use the NEKO filter and it should be applied to all URLs (.)

 

Ajax little tricks…

  • ajaxSingle = true
    this attribute should be true for any ajax component whose only value is required at server time so that whole ajax request map should not be posted to server.  
  • limitToList = ture
    this attribute should be true for any ajax compoenent who will reRender only the components specified in its reRender attribute list. All other components not specified in the reRender list will no longer reRender upon request complition.
  • immediate = true
    This trick should be used by setting extra effort. This property will submit the value and skips validation phase and set the value immediatly into backing bean.

Your positive feedback and comments are welcomed for JSF ajax optimization.

About Faisal Basra

Check Also

Securing Spring Remoting by Spring Security

If you are exposing your some of services by Spring Remoting’s Http Invoker, most probably ...