JSF Configuration

Version 1 by Mark Collette
on Jun 07, 2011 16:57.


 
compared with
Current by Mircea Toma
on Dec 01, 2014 11:16.


 
Key
These lines were removed. This word was removed.
These lines were added. This word was added.

View page history


There are 6 changes. View first change.

 h2. 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.
  
 h4. 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.
  
 h5. javax.faces.PROJECT_STAGE
  
 _Default is Production_
  _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 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.
  
 {code:xml} <context-param>
  <param-name>javax.faces.PROJECT_STAGE</param-name>
  <param-value>Production</param-value>
  </context-param>
 {code}
 
 h5. com.sun.faces.defaultResourceMaxAge
  
_Default is 604800_
  _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 PRJECT_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.
  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.
  
 {code:xml} <context-param>
  <param-name>com.sun.faces.defaultResourceMaxAge</param-name>
  <param-value>604800</param-value>
  </context-param>
 {code}
  
 h5. 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|https://docs.oracle.com/cd/E41236_01/wlp.1036/e14244/jsf.htm#CHDCAHBG].
  
 {code:xml} <context-param>
  <param-name>com.sun.faces.namespaceParameters</param-name>
  <param-value>true</param-value>
  </context-param>
 {code}

© Copyright 2014 ICEsoft Technologies Canada Corp.