JBoss.orgCommunity Documentation

Chapter 5. Advanced features

5.1. JSF 2 integration
5.2. Error handling
5.2.1. Client-side errors
5.2.2. Server-side errors
5.3. Other functions
5.4. Resource loading
5.4.1. Configuring ResourceServlet
5.4.2. Resource mapping
5.4.3. Resource loading strategies

Read this chapter for details on some of the advanced features and configuration possibilities for the RichFaces framework.

JavaServer Faces (JSF) is the Java-based web application framework upon which the RichFaces framework has been built. RichFaces is now integrated with JSF 2, which features several improvements to the framework.

RichFaces allows standard handlers to be defined for processing different application exceptions. Custom JavaScript can be executed when these exceptions occur.

RichFaces provides a number of advanced functions, such as managing user roles and identifying elements. Refer to the Functions chapter in the RichFaces Component Reference for further details.

Resources which RichFaces uses in components, like style sheets, JavaScript code or images are handled by standard JSF resource handling.

However JSF resource handling feature falls short when using static resources which refers to another resources (style sheets refering to images, JavaScript refering to style sheets). These resources doesn't carry informations necessary to address JSF resources (servlet context path, servlet mapping, library name).

RichFaces provides ResourceServlet which handles framework static resources:

RichFaces resources are determined by notion of resource libraries and loaded by standard JSF resource handling mechanism.

There are situations where it may be favourable to use alternative resource location:



Resource loading strategies are special configuration of resource mapping.

RichFaces framework bundles static versions of all components' resources which are processed to optimize performance in certain scenarios:

Previous features aren't configured directly, it is necessary to choose project stages in which given feature will be applied.

It is necessary to choose stages, where compression is applied and where packed resource will be used. If both compression and packing are disabled, simple static resources will be served.

It is possible to provide following options for project stages: Development, UnitTest, SystemTest, Production or keywords None and All.

For configuration, you can use any combination of project stages (separated by commas) or keywords None (for feature turned off in all stages) or All (for feature turned off in all stages).

Compression is configured in web.xml using context-param org.richfaces.resourceMapping.compressedStages. Compression is by default set to Production,SystemTest, enabling this feature for production and system testing.

Packing is configured in web.xml using context-param org.richfaces.resourceMapping.packedStages. Packing is by default set to All, enabling this feature in all stages.


Custom resource mapping and Resource loading strategies

Resource loading strategies are just special case of resource mapping, thus once you will provide custom resource mapping configuration or location, bundled default resources won't be referenced correctly.

For using compressed/packed resources you will need to copy properties from one of files located in richfaces-components-ui.jar:/META-INF/richfaces/staticResourceMapping/.