### Create new RichFaces Documentation Jira issue

Summary
255 characters left
Description
Environment
This will launch the RichFaces Jira page - to complete your feedback please login if needed, and submit the Jira.

JBoss.org Community Documentation

- Prev
- Next

## 4.5. Component resources registration

expand all

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:

- an icon

      ...

      <resource>

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

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

      </resource>

      ...

- the inputDate.xcss file

      ...

      <resource>

          <name>org/mycompany/renderkit/html/css/inputDate.xcss</name>

          <path>org/mycompany/renderkit/html/css/inputDate.xcss</path>

      </resource>

      ...

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

### 4.5.1. resource-config.xml file format

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.

- Prev4.4. Creating a Renderer
- Top of page
- Front page
- Next4.6. Extending a UIInput class