Fix your Richfaces AJAX (performance) problems

Richfaces supports AJAX functionality in a lot of it components. However a servlet filter is needed for correct functioning of partial page refreshes.

In this post we’ll show you how to add this filter and at the same time optimize Richfaces performance.

The following Richfaces filter is defined in the web.xml:

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

What this filter does, is to ‘tidy’ all HTML HTTP Responses so that they are valid XHTML (thus XML compliant). This is needed as dynamic DOM updates in the browser need correct XML.

If you don’t define this filter, it is possible that you’ll not see your AJAX update being rendered on the screen, although you’ll see the html response coming back in eg. Firebug

Of course, parsing HTML incurs a performance overhead.
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:

        <servlet-name>Faces Servlet</servlet-name>

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:


Here we say we only use the NEKO filter and it should be applied to all URLs (.)
There is more configuration possible, like using NONE for some pages that don’t need HTML correction to further speedup things if needed.

Example can be found at:

Warning: count(): Parameter must be an array or an object that implements Countable in /home/javablog/web/wp-includes/class-wp-comment-query.php on line 405

5 thoughts on “Fix your Richfaces AJAX (performance) problems”

  1. Hi,
    with spring webflow 2.0 the init param ‘forceparam’ should be true, in order to get the partly page refresh working.

    RichFaces Filter


    And the filter should be applied to the MVC Dispatcher Servlet as well.

    I do not use the NEKO parser.


  2. We are using RichFaces and are having performance problems and I have a sneaking suspicion that is due to the fact that my Views are not being cached and are being rebuilt on every request.

    What is the easy way to determine if a view is being cached or not cached and determining what the cause of this would be.


  3. hi,

    I apply the configuration you mentioned above. but I got the error below;

    java.lang.NoClassDefFoundError: org/cyberneko/html/filters/ElementRemover

    do you know how can I overcome this problem?

    kind regards,

  4. Which Richfaces version are you using? The error indicates that the Neko parser is not available in any of your packaged jars. I believe that in the past the Neko filter was included in the richfaces jar itself. I haven’t checked with the latest versions…

Leave a Reply

Your email address will not be published. Required fields are marked *