Optimizing JSF Richfaces Applications
Saturday, April 25, 2009 1:13JSF 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.
<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.

Jigar says:
June 14th, 2009 at 11:56 am
i tried using the optimization techniques mentioned in the post,but with little success. May be i might be not doing it right. This is what i have done, can u let me know if there is anything wrong with these.
1: Even after addign LoadStyle And Script strategy in the context param i see all Richfaces.js files in the repsonse i get with all the requests that go through.
2: I also tried implementing the NEKO parser mentioned but when i tried to forward the request i got an ClassNotFoundException for org/apache/xerces/xni/parser/XMLConfigurationException . What should be done in both the cases. I would be a great help if you can throw some light. Thanks
Faisal says:
June 20th, 2009 at 12:46 am
@ Jigar
For your point number 1, actually i have decided to load all styles and script at once when the first page of application is accessed, its benefit can be while navigating to other richfaces, then no newer script file or css file will be loaded because all files were loaded before. So, you have to decide based on your application requirement.
and changing the parser should not effect because they all do the same job rendering content data but with different strategy.
So, to more precisely can you please your web.xml configs, so I can think exactly ..
brielvevecich says:
November 25th, 2009 at 9:06 pm
Seems like you are a true expert. Did ya study about the theme? hehe
Faisal says:
November 27th, 2009 at 7:43 pm
Yes, recently I have been working to develop theme in Richfaces….. If you need help regarding, just let me know. I will share my experience here.
M_ologin says:
December 8th, 2009 at 8:12 pm
Thanks for your advices. As I run Yslow, my report states that I should also:
- use a content delivery network
- add expires headers
- compress components with gzip.
Is there an easy way to do this through Richfaces xml settings?
raghab says:
December 24th, 2009 at 5:05 pm
Hi ,
I have some problem with modal panel
i want to render a outputText field in parentwindow on button click in modalpanel
this works when i directly put the button in modalpanel,but does not work if i include the button in a page which is included in modalpanel
follwing is the code sample …
parentpage.jsp
——————–
includetest.jsp
——————
parentpage.java
———————
package com.test;
import javax.faces.event.ActionEvent;
public class parentpage {
private String outputval;
private int count;
public parentpage() {
// TODO Auto-generated constructor stub
outputval = “Before Change”;
count=0;
}
public String getOutputval() {
return outputval;
}
public void setOutputval(String outputval) {
this.outputval = outputval;
}
public void changeoutputval(ActionEvent event) {
outputval = “Got that”;
}
}
Click on “modal direct click” outputval is updated
Click On “modal included click” outputval is not updated
Please guide me in this regard..
Juan Siefferman says:
January 21st, 2010 at 8:16 am
Online marketing is not just for the effective product, producing a website or for letting customers buy items ongoing. Online marketing can also include how a business proprietor can engage a work squad. The amount of people who are studying computers, web design, and learning to host websites proves just how successful online marketing can make the employer, the employees, and the independent contractors. And with a comfortable Internet savvy team, your business profits can increase too.
Francesca Pearl says:
January 23rd, 2010 at 3:21 pm
Hey – nice website, just looking around some blogs, seems a pretty nice platform you are using. I’m currently using Wordpress for a few of my blogs but looking to change one of them over to a platform similar to yours as a trial run. Anything in particular you would recommend about it?
Arun says:
February 5th, 2010 at 2:14 am
Hi,
My application loads about 2000 rows in a datatable UI at once. So, inorder to improve the performance, i implemented pagination using richfaces and i have checkbox as one of the column. My problem is : one, i am not able to maintain the status of checbox value during pagination and two, even though i use pagination i am still loading all datas in the list. Can you help me in this issue? Thanks
Gift Sam says:
March 9th, 2010 at 7:52 pm
Hi,
First of all i would like to thank you for this excellent article. I had a problem while implementing Richfaces theme using the latest jar files(3.3.2.SR1) for my JSF application. It works fine in firefox and chrome. But in Internet explorer, the components used in the pages are not rendering properly after an ajax action(Only in some cases, for eg, Problem occuring in rich faces calender, rich combobox, component is not displaying after an ajax action). Also while the application runs in the Internet Explorer, I am getting the browser script error “Object Doesnt support this property or method”. But I never get this problem in firefox or chrome. Kindly give some valuable inputs to resolve this issue.
Thanks in Advance!!