Thursday, April 26, 2012

How-to: applying JSF runtime configuration parameters in JSF 2.0

Servlet containers support application configuration parameters that may be customized by including <context-param> elements in the web application deployment descriptor.  Following application configuration parameter are supported in all JSF 2.0 implementations:


Param Name
javax.faces.CONFIG_FILES
Comma-delimited list of context-relative paths to faces config files. JSF application will load the files before loading default config file"/WEB-INF/faces-config.xml". If "/WEB-INF/faces-config.xml" is present in the list, it will be ignored.null1.2 and 2.0
javax.faces.DEFAULT_SUFFIX
Change the default suffix for JSP views. Allow the web application to define an alternate suffix for JSP pages containingJSF content..jsp1.2 and 2.0
javax.faces.LIFECYCLE_ID
ID for alternate Lifecycle implementations. Lifecycle identifier of the Lifecycle instance to be used when processing JSF requests for this web application. If not sp ecified, the JSF default instance, identified by LifecycleFactory.DEFAULT_LIFECYCLE, will be used.null1.2 and 2.0
javax.faces.STATE_SAVING_METHOD
The location where state information is saved. Valid values are “server” (typically saved in HttpSession ) and “client (typically saved as a hidden field in the subsequent form submit). If not specified, the default value “server” will be used.server1.2 and 2.0
javax.faces.DATETIMECONVERTER _DEFAULT_TIMEZONE_IS _SYSTEM_TIMEZONE
Controls if DateTimeConverter instances use the system timezone (if true) or GMT (if false).false2.0
javax.faces.DATETIMECONVERTER _DEFAULT_TIMEZONE_IS _SYSTEM_TIMEZONE
Controls if DateTimeConverter instances use the system timezone (if true) or GMT (if false).false2.0
javax.faces.DISABLE_FACELET_JSF_VIEWHANDLER
Disables the built-in Facelet ViewHandler. Useful for applications that use legacy Facelets implementation. If this param is set to "true", the default ViewHandler behaves as specified in the latest 1.2 version of JSF specification. Any behavior specified in Section 7.5 “ViewHandler” and implemented in the default ViewHandler that pertains to handling requests for pages authored in the JSF isn't executed by the runtime.false2.0
javax.faces.FACELETS_LIBRARIES
Semicolon-separated list of paths, starting with “/” (without the quot es), to Facelet tag libraries. The runtime interprets each entry in the list as a path relative to the web application root and interprets the file found at that path as a facelet tag library. null2.0
facelets.LIBRARIES
Semicolon-separated list of paths to Facelet tag libraries. Used for backward-compatibility with legacy Facelets implementation. Considered as an alias to javax.faces.FACELETS_LIBRARIES.null2.0
javax.faces.FACELETS_BUFFER_SIZE
The buffer size set on the response.-1 (no assigned buffer size)2.0
facelets.BUFFER_SIZE
The buffer size set on the response. Used for backward-compatibility with legacy Facelets implementation.-1 (no assigned buffer size)2.0
javax.faces.DECORATORS
Semicolon-delimited list of javax.faces.view.facelets.TagDecorator implementations. These decorators will be loaded when the first request for a Facelets VDL view hits the ViewHandler for page compilation. The runtime also considers the facelets.DECORATORS param name as an alias to this param name for backwards compatibility with existing facelets tag libraries.null2.0
facelets.DECORATORS
Semicolon-delimited list of TagDecorator implementations. Used for backward-compatibility with legacy Facelets implementation alias for javax.faces.DECORATORS.null2.0
javax.faces.FACELETS_REFRESH_PERIOD
Time in seconds that facelets should be checked for changes since last request. When a page is requested, what interval in seconds should the compiler check for changes. If you don't want the compiler to check for changes once the page is compiled, then use a value of -1. Setting a low refresh period helps during development to be able to edit pages in a running application.implementation-specific2.0
facelets.REFRESH_PERIOD
Time in seconds that facelets should be checked for changes since last request. A value of -1 disables refresh checking. Used for backward-compatibility with legacy Facelets implementation alias for javax.faces.FACELETS_REFRESH_PERIOD.implementation-specific2.0
javax.faces.FACELETS_RESOURCE_RESOLVER
An implementation of javax.faces.view.facelets.ResourceResolver. If this param is set, the runtime interprets its value as a fully qualified classname of a java class that extends javax.faces.view.facelets.ResourceResolver and has a zero argument public constructor or a one argument public constructor where the type of the argument is ResourceResolver. If this param is set and its value does not conform to those requirements, the runtime logs a message and continues. If it does conform to these requirements and has a one-argument constructor, the default ResourceResolver will be passed to the constructor. If it has a zero argument constructor it is invoked directly. In either case, the new ResourceResolver replaces the old onenull2.0
facelets.RESOURCE_RESOLVER
An implementation of javax.faces .view.facelets .ResourceResolver. Used for backward-compatibility with legacy Facelets implementation alias for javax.faces.FACELETS_RESOURCE_RESOLVER.null2.0
javax.faces.FACELETS_SKIP_COMMENTS
If set to "true", runtime strips XML comments out of Facelets before delivering to the client.false
facelets.SKIP_COMMENTS
If set to "true", JSF runtime strips XML comments out of Facelets before delivering to the client. Used for backward-compatibility with legacy Facelets implementation alias for javax.faces.FACELETS_SKIP_COMMENTS.false2.0
javax.faces.FACELETS_SUFFIX
Set the suffix for Facelet xhtml files..xhtml
facelets.SUFFIX
Set the suffix for Facelet xhtml files. Used for backward-compatibility with legacy Facelets implementation..xhtml
javax.faces.FACELETS_VIEW_MAPPINGS
Semicolon-separated list of Facelet files that don't use the default facelets suffix. If this param is set, the runtime interprets it as a semicolon (;) separated list of strings that is used to forcibly declare that certain pages in the application must be interpreted as using Facelets, regardless of their extension.null2.0
facelets.VIEW_MAPPINGS
Semicolon-separated list of Facelet files that don't use the default facelets suffix. Used for backward-compatibility with legacy Facelets implementation alias for javax.faces.FACELETS_VIEW_MAPPINGS.null2.0
javax.faces.FULL_STATE_SAVING_VIEW_IDS
Semicolon-separated list of view IDs that must save state using the JSF 1.2-style state saving.null
javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES _AS_NULL
If true, consider empty UIInput values to be null instead of empty string. If the javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL context parameter value is true (ignoring case), and UIInput.getSubmittedValue() returns a zero-length String call UIInput.setSubmittedValue(null) and continue processing using null as the current submitted value.false2.0
javax.faces.PARTIAL_STATE_SAVING
If true, use the JSF2 partial state saving for views. For previous versions has no effects.false, if WEB-INF/faces-config.xml does not declare JSF 2.0 schema. true, otherwise2.0
javax.faces.PROJECT_STAGE
A human readable string describing where this particular JSF application is in the software development lifecycle. Set the project stage to "Development", "UnitTest", "SystemTest", or "Production". It is also possible to set this value via JNDI. See the javadocs for Application.getProjectStage().Production2.0
javax.faces.SEPARATOR_CHAR
The context param that allows the character used to separate segments in a UIComponent clientId to be set on a per-application basis.null, interpreted as default (:) value2.0
javax.faces.VALIDATE_EMPTY_FIELDS
If "true" all submitted fields will be validated. This is necessary to allow the model validator to decide whether null or empty values are allowable in the current application. If the value is "false", null or empty values will not be passed to the validators. If the value is the string “auto”, the runtime will check if JSR-303 Beans Validation is present in the current environment. If so, the runtime will proceed as if the value “true” had been specified. If JSR-303 Beans Validation is not present in the current environment, the runtime will proceed as if the value “false” had been specified. If the param is not set, the system behaves as if the param was set with the value “auto”.auto2.0
javax.faces.validator.DISABLE_DEFAULT_BEAN_VALIDATOR
If "true", disable JSR-303 Bean Validation, and If this param is set, eg. the runtime will not automatically add the validator with validator-id equal to the value of the symbolic constant javax.faces.validator.VALIDATOR_ID to the list of default validators. Setting this parameter to true will have the effect of disabling the automatic installation of Bean Validation to every input component in every view in the application, though manual installation is still possible.false2.0

The JSF engine parameters are case sensitive. If the value specified for a parameter is comprised of two or more words separated by spaces, you must add quotation marks around the value.

You have here a simple example of use of configuration parameters:
<context-param>
         <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
         <param-value>.abc</param-value>
</context-param> 

In addition to the parameters neutral terms of JSF implementation, there exist also implementation specific parameters for Mojarra, MyFaces and so on.

3 comments:

  1. Thanks for your informative article, Your post helped me to understand the future and career prospects & Keep on updating your blog with such awesome article.
    python training in rajajinagar
    Python training in bangalore
    Python training in usa

    ReplyDelete
  2. I am definitely enjoying your website. You definitely have some great insight and great stories. 
    AWS Training in pune
    AWS Online Training

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete