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

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 experience of building mission critical, large scale application in banking, finance & telecom field.

, ,

40 Responses to Optimizing JSF Richfaces Applications

  1. Jigar June 14, 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

  2. Faisal (http://www NULL.javaplex NULL.com) June 20, 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 ..

  3. brielvevecich (http://johnsblog NULL.this-war NULL.net/) November 25, 2009 at 9:06 pm #

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

  4. Faisal (http://www NULL.javaplex NULL.com) November 27, 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.

  5. M_ologin December 8, 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?

  6. raghab December 24, 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..

  7. Juan Siefferman (http://www NULL.affiliatecrunch NULL.com) January 21, 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. :) (http://www NULL.affiliatecrunch NULL.com)

  8. Francesca Pearl (http://kezanari NULL.com) January 23, 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?

  9. Arun February 5, 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

  10. Gift Sam (http://www NULL.technicalbrainwave NULL.wordpress NULL.com) March 9, 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!!

  11. Mike Machadow May 12, 2010 at 10:44 pm #

    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?

  12. Jose June 24, 2010 at 1:53 am #

    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

  13. htc hero (http://www NULL.htc-hero NULL.com) July 26, 2010 at 7:50 am #

    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!

  14. Carlo Fant (http://recenthealtharticles NULL.org/48762/how-to-opt-for-the-perfect-tattoo-from-the-infinite-multitude-of-tattoo-styles/) January 29, 2011 at 1:28 pm #

    Wonderful one, thank you for the tip

  15. John Walsh (http://code NULL.google NULL.com/p/granule/) April 16, 2011 at 3:19 am #

    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/)

  16. Cars (http://crape265 NULL.posterous NULL.com/) February 1, 2012 at 8:41 am #

    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?

  17. Automotive JDM (http://738luloff NULL.posterous NULL.com/) February 3, 2012 at 4:11 pm #

    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!

  18. the true 0800 numbers February 9, 2012 at 5:06 am #

    I’ve recently started a blog, and the information you offer on this website has helped me a lot. Thank you for all of your time & work.

  19. accounting vs finance degree (https://www NULL.tumblr NULL.com/login) February 25, 2012 at 6:33 pm #

    I am hardly ever impressed by help and advice articles but this article just established plenty authentic and precious information that I just have to acknowledge it. I am well-aware of all the importance of this information and salute you with a sincere thanks for your insight. I just tried to bookmark your site to share but I can’t, I reckon your bookmark symbol isn’t working. Just to let you know. Carry on with posting great and unique contents. Cheers !

  20. Adam (http://www NULL.ncfa NULL.ie/index NULL.php/member/112233/) March 6, 2012 at 2:17 am #

    Howdy! Someone in my Facebook group shared this website with us so I came to give it a look. I’m definitely loving the information. I’m book-marking and will be tweeting this to my followers! Wonderful blog and wonderful design and style.

  21. Lyle (http://www NULL.unrarx NULL.com/vanilla/comments NULL.php?DiscussionID=17330) April 1, 2012 at 4:06 pm #

    http://www.silverbackmusic.net/index.php/member/249603/ (http://www NULL.silverbackmusic NULL.net/index NULL.php/member/249603/)

  22. yahoo coupon (http://greatpreowned NULL.com/yahoo-web-hosting-coupon-codes/) June 5, 2012 at 1:58 am #

    kvzplkbwbqmfy, yahoo web hosting (http://greatpreowned NULL.com/yahoo-web-hosting-coupon-codes/), XHgfvQM, [url=http://greatpreowned.com/yahoo-web-hosting-coupon-codes/]yahoo web hosting coupon[/url], roJqnZH, http://greatpreowned.com/yahoo-web-hosting-coupon-codes/ (http://greatpreowned NULL.com/yahoo-web-hosting-coupon-codes/) yahoo web hosting, CwvhGBt.

  23. Mature porn videos (http://chiefbodega NULL.com/) June 14, 2012 at 1:01 am #

    xzasfkbwbqmfy, Mature porn (http://chiefbodega NULL.com/), CqIIMGD, [url=http://chiefbodega.com/]Gold mature porn[/url], lmOPRNW, http://chiefbodega.com/ (http://chiefbodega NULL.com/) Hamster mature porn, BYyAkmC.

  24. kbwbqmfy (http://pornsks4all NULL.com/) June 14, 2012 at 1:05 am #

    kbwbqmfy (http://pornsks4all NULL.com/), oTMLkXT, [url=http://pornsks4all.com/]kbwbqmfy[/url], WwdazGE, http://pornsks4all.com/ (http://pornsks4all NULL.com/) kbwbqmfy, EOzLjic.

  25. V2 Cigs Review (http://tjdcompany NULL.com/v2-cigs NULL.html) June 14, 2012 at 5:43 am #

    afpoykbwbqmfy, V2 cigs coupon code (http://tjdcompany NULL.com/v2-cigs NULL.html), XfeEFDT, [url=http://tjdcompany.com/v2-cigs.html]V2Cigs[/url], eUdnyjC, http://tjdcompany.com/v2-cigs.html (http://tjdcompany NULL.com/v2-cigs NULL.html) V2cigs review, UJNnKIZ.

Trackbacks/Pingbacks

  1. kizi (http://www NULL.kizinew NULL.net) - December 6, 2012

    kizi…

    Wonderful work! That is the kind of info that should be shared across the net. Shame on search engines…

  2. jfd98ayhcim (http://jfdg98ayhcdi4gmf NULL.com/) - December 18, 2012

    Great website…

    please visit the sites we follow, including this one, as it represents our picks from the web…

  3. lida hizli zayiflama (http://www NULL.lidahizlizayiflama NULL.com) - December 18, 2012

    Cool sites…

    Here are some of the sites we recommend for our visitor…

  4. lida (http://www NULL.lidailezayiflama NULL.com) - December 18, 2012

    Great website…

    please visit the sites we follow, including this one, as it represents our picks from the web…

  5. lida (http://www NULL.lida-slimming NULL.com) - December 19, 2012

    Great Content…

    we like to honor many other internet sites on the web, even if they aren’t linked to us, by linking to them. Under are some webpages worth checking out…

  6. lida (http://www NULL.lidazayiflama NULL.info) - December 19, 2012

    Online Article…

    Every so often in a while we choose blogs that we read. Listed underneath are the latest sites that we choose…

  7. دردشة صوتية (http://chat-voice1 NULL.com/) - December 19, 2012

    So cool…

    The information provided in the article are some of the best available…

  8. lida (http://www NULL.lidahapiankara NULL.com) - December 19, 2012

    Sources…

    Here are some of the sites we recommend for our visitor…

  9. lida (http://www NULL.zayiflamailaci NULL.gen NULL.tr) - December 20, 2012

    Cool sites…

    Here are some of the sites we recommend for our visitor…

  10. jfd98ayhcimg (http://jfdg98ayhcdi4gkmf NULL.com/) - December 20, 2012

    So cool…

    The information provided in the article are some of the best available…

  11. training management systems (http://www NULL.getadministrate NULL.com) - December 20, 2012

    Websites we think you should visit…

    we like to honor many other internet sites on the web, even if they aren’t linked to us, by linking to them. Under are some webpages worth checking out…

  12. Cash Flow (http://www NULL.HafnerMerchants NULL.com) - December 21, 2012

    Sources…

    Here are some of the sites we recommend for our visitor…

  13. Make Money (http://www NULL.CAKMerchants NULL.com) - December 21, 2012

    Cool sites…

    Here are some of the sites we recommend for our visitor…

  14. Cash Advances (http://www NULL.AJMerchants NULL.com) - December 21, 2012

    Sources…

    Here are some of the sites we recommend for our visitor…

  15. Maximize your Profits (http://www NULL.BeaverCreekMerchants NULL.com) - December 21, 2012

    Websites we think you should visit…

    we like to honor many other internet sites on the web, even if they aren’t linked to us, by linking to them. Under are some webpages worth checking out…

Leave a Reply