background image

Registering a Custom Component

<< The dataScroller Component Tag | JavaServer Faces Application >>
<< The dataScroller Component Tag | JavaServer Faces Application >>

Registering a Custom Component

<display-name>Next</display-name>
<facet-name>next</facet-name>
</facet>
If a component that supports facets provides its own rendering and you want to include facet
elements in the application configuration resource file, you need to put them in the
component's configuration rather than the renderer's configuration.
Registering a Custom Component
In addition to registering custom renderers (as explained in the preceding section), you also
must register the custom components that are usually associated with the custom renderers.
Here is the component element from the application configuration resource file that registers
AreaComponent
:
<component>
<component-type>DemoArea</component-type>
<component-class>
com.sun.bookstore6.components.AreaComponent
</component-class>
<property>
<property-name>alt</property-name>
<property-class>java.lang.String</property-class>
</property>
<property>
<property-name>coords</property-name>
<property-class>java.lang.String</property-class>
</property>
<property>
<property-name>shape</property-name>
<property-class>java.lang.String</property-class>
</property>
</component>
The component-type element indicates the name under which the component should be
registered. Other objects referring to this component use this name. For example, the
component-type
element in the configuration for AreaComponent defines a value of DemoArea,
which matches the value returned by the AreaTag class's getComponentType method.
The component-class element indicates the fully qualified class name of the component. The
property
elements specify the component properties and their types.
If the custom component can include facets, you can configure the facets in the component
configuration using facet elements, which are allowed after the component-class elements.
See
"Registering a Custom Renderer with a Render Kit" on page 455
for further details on
configuring facets.
Registering a Custom Component
Chapter 14 · Configuring JavaServer Faces Applications
457