Create new RichFaces Documentation Jira issue

This will launch the RichFaces Jira page - to complete your feedback please login if needed, and submit the Jira.

JBoss.orgCommunity Documentation

4.5. Component resources registration

The <inputDate> component has a number of resources that should be registered in the resource-config.xml file. If the resource is registered, the RichFaces filter will send a request to the ResourceBuilder class in order to create and to deliver the resource.

Hence, you need to proceed to the inputDate/src/main/config/resources directory and register the following resources in the resource-config.xml file:

In this resource-config.xml files you could find a complete example of the resource-config.xml for the <inputDate> component.

The resource-config.xml is a file for resources registration. Note, that the resource-config.xml should appear in the META-INF folder after the component building.

This file has the <resource-config> root element with nested <resource> elements.

It is possible to register static resources (images, JavaScript , CSS, XCSS, SWF, (X)HTML, XML, Log files), dynamic created images, component-incapsulated, JAR resources, etc.

Here is a simple example of the image registration:


...
<resource>
    <name>org/mycompany/renderkit/html/images/inputDate.png</name>
    <path>org/mycompany/renderkit/html/images/inputDate.png</path>
</resource>
...

There are two elements in the example above: an obligatory <name> element which defines resource name and a <path> element which defines the path to the resource. The <path> element is optional as it is possible to register dynamic resources with the "class" attribute. For example you could register a dynamically created image as it is shown in the following example:


...
<resource class="org.mycompany.renderkit.html.images.inputDate">
    <name>org.mycompany.renderkit.html.images.inputDate</name>
</resource>
...

With the help of the <cacheable> element you could manage whether the resource is cached or not. If the value of this element is "true", the resource is cached on the server and also on the client sides:


...
<resource class="org.mycompany.renderkit.html.images.inputDate">
    <name>org.mycompany.renderkit.html.images.inputDate</name>
    <cacheable>true</cacheable>
</resource>
...

You could start a session for the some resource using <session-aware> element set to "true":


...
<resource>
    <name>org/mycompany/renderkit/html/scripts/inputDate.js</name>
    <path>org/mycompany/renderkit/html/scripts/inputDate.js</path>
    <session-aware>true</session-aware>
</resource>
...

Sometimes the definition of a content type of the resource is needed, so it is possible to add the <content-type> element with the proper MIME type.

You could also define a custom renderer for the resource:


...
<resource>
    <name>org/mycompany/renderkit/html/scripts/inputDate.js</name>
    <path>org/mycompany/renderkit/html/scripts/inputDate.js</path>
    <renderer class="org.ajax4jsf.resource.ScriptRenderer"/>
</resource>
...

It is possible to specify a MIME type for the resource renderer using the <content-type> element.