«

»

Apr
25

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.

VN:F [1.9.13_1145]
Rating: 7.6/10 (5 votes cast)
VN:F [1.9.13_1145]
Rating: +1 (from 1 vote)
Optimizing JSF Richfaces Applications , 7.6 out of 10 based on 5 ratings

About the author

Faisal Basra

Faisal Basra is an independent consultant, software developer, writer, blogger, speaker, architect and technology leader in Lahore, Pakistan. He has been a professional software developer since 2008, has been writing code since 2006. Having hands on experience of popular Java EE frameworks & technologies like JSF, Spring, Hibernate, Enverse, JPA, Richfaces, Primefaces, JSP/Servlet. I have taken many initiatives while working with teams. Some of includes Automated Build & Release Management system via Hudson, Maven, Archiva & SVN. Blogging is my hobby and I also initiated blog at corporate level from setting up complete blog for company, content generation strategy and visibility over the Internet by Internet Marketing. Framworks & Technologies: JSF, Richfaces, Primefaces, Openfaces, Struts, Hibernate, Spring, ORMLite Tools & Servers: jUnit, Log4j, Maven, Eclipse, MyEclipse, NetBeans, Tomcat, Jboss, WebLogic Mobile Development: Google Android Marketing: Internet Marketing, Mobile App Marketing

Permanent link to this article: http://www.javaplex.com/blog/optimizing-jsf-richfaces-applications/

17 comments

  1. Jigar says:

    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

    VA:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
  2. Faisal (http://www NULL.javaplex NULL.com) says:

    @ 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 ..

    VA:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
  3. brielvevecich (http://johnsblog NULL.this-war NULL.net/) says:

    Seems like you are a true expert. Did ya study about the theme? hehe

    VA:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
  4. Faisal (http://www NULL.javaplex NULL.com) says:

    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.

    VA:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
  5. M_ologin says:

    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?

    VA:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
  6. raghab says:

    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..

    VA:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
  7. Juan Siefferman (http://www NULL.affiliatecrunch NULL.com) says:

    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. :) (http://www NULL.affiliatecrunch NULL.com)

    VA:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
  8. Francesca Pearl (http://kezanari NULL.com) says:

    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?

    VA:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
  9. Arun says:

    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

    VA:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
  10. Gift Sam (http://www NULL.technicalbrainwave NULL.wordpress NULL.com) says:

    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!!

    VA:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
  11. Mike Machadow says:

    Hi,
    Hope some can help, I have an extendedDataTable in a a tab (this tab is selected by default) and for some reason when the site its initialy render (tabPanel with several tabs) it will only render part of it and wont load the rest of the tabs. Now, if I ask the tab to be rerendered it works fine. but the problem is thatinitially it habngs up the rendering of the whole site.

    Any tips?

    VA:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
  12. Jose says:

    Hi there,

    Im having memory problems using richfaces, memory of my tomcat server is increasing ridicuously and I get my server at memory top usage. I m setting variblas for CATALINA and JAVA on server side, and using Xms and Xmx parameters to run apache, but Im getting the same problems.

    I you could helpme with this, I will appreciate you…

    Thanks

    VA:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
  13. htc hero (http://www NULL.htc-hero NULL.com) says:

    Does anybody know which sort of video information are supported? I keep in mind the Instinct only could dl 3gp using opera mini. I downloaded the twist ap, maybe that’s the problem? How can I watch videos from sites apart from youtube? Which file types? Usually I’m given the option of 3gp or mpeg4. Can’t get either to work. Thanks on your time! Rattling I want I used to be eligible for the upgrade to EVO!

    VA:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
  14. Carlo Fant (http://recenthealtharticles NULL.org/48762/how-to-opt-for-the-perfect-tattoo-from-the-infinite-multitude-of-tattoo-styles/) says:

    Wonderful one, thank you for the tip

    VA:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
  15. John Walsh (http://code NULL.google NULL.com/p/granule/) says:

    More handy of optimizing is using on fly libraries to combine JS/JSF

    http://code.google.com/p/granule/ (http://code NULL.google NULL.com/p/granule/)

    VA:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
  16. Cars (http://crape265 NULL.posterous NULL.com/) says:

    I’ve been absent for some time, but now I remember why I used to love this site. Thanks, I’ll try and check back more often. How often do you update your website?

    VA:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.13_1145]
    Rating: 0 (from 0 votes)
  17. Automotive JDM (http://738luloff NULL.posterous NULL.com/) says:

    I think other web site proprietors should take this website as an model – very clean and fantastic style and design, as well as the content. You’re an expert in this topic!

    VA:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.13_1145]
    Rating: 0 (from 0 votes)

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>