JSF Configuration

Table of Contents

JSF Configuration

JSF has it's own configuration context parameters, which may optionally be specified, to further tune or configure applications. These context parameters are set in the web.xml file of your application. Various JSF implementations, such as Mojarra, also have their own configuration context parameters.

Caching Context Parameters

These context parameters affect how resources will be cached. JSF pages use components which themselves register resources either programmatically or statically via @ResourceDependency annotations. These resources typically consist of Javascript and CSS files, but can be any other files that the page contains.

javax.faces.PROJECT_STAGE

Default is Production

When the PROJECT_STAGE is set to Production, and a resource is within its cached duration, then the web browser can avoid going to the server at all for the resource. If it's beyond the duration, or the user has pressed the Refresh button, then the browser may request if the resource has been updated, which can either return an HTTP 304 code saying that the resource is still valid in the browser's cache, or it will return an HTTP 200 code and serve out the resource, if it has been updated.

When the PROJECT_STAGE is set to Development, the cache duration is ignored, so the browser will always request if the resource has been updated, and use the HTTP 304 and 200 accordingly. So, caching is not completely disabled, as it can still avoid downloading the resource, but it will still communicate with the server.

    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Production</param-value>
    </context-param>
com.sun.faces.defaultResourceMaxAge

Default is 604800

This parameter is specific to Mojarra's JSF implementation. The default is about 10 minutes, which is not really that long. It's recommended that production applications specify a longer caching duration, for example 2 weeks. Again, this only applies when the PROJECT_STAGE has been set to Production, and allows the browser to avoid any communication with the server, in regards to cached resources. There is no means for setting different cache durations for different resources, this globally applies to all resources.

    <context-param>
        <param-name>com.sun.faces.defaultResourceMaxAge</param-name>
        <param-value>604800</param-value>
    </context-param>
com.sun.faces.namespaceParameters

Default is false

This parameter is specific to Mojarra's JSF implementation. When enabled the JSF implementation will namespace the client IDs of the components rendered in the page. The AJAX parameters such as javax.faces.source, javax.faces.partial.event and javax.faces.partial.execute are also prefixed. The prefix is taken off the JSF view root which in the case of portal environment will have different values for each portlet. ICEfaces extends the namespacing to all of its custom parameters. See more here.

    <context-param>
        <param-name>com.sun.faces.namespaceParameters</param-name>
        <param-value>true</param-value>
    </context-param>
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

© Copyright 2018 ICEsoft Technologies Canada Corp.