background image

Registering a Custom Renderer

<< The navigation-case Element | The dataScroller Component Tag >>
<< The navigation-case Element | The dataScroller Component Tag >>

Registering a Custom Renderer

Registering a Custom Renderer with a Render Kit
When the application developer creates a custom renderer, as described in
"Delegating
Rendering to a Renderer" on page 427
, you must register it using the appropriate render kit.
Because the image map application implements an HTML image map, AreaRenderer (as well
as MapRenderer) should be registered using the HTML render kit.
You register the renderer using the render-kit element of the application configuration
resource file. Here is the configuration of AreaRenderer from the Duke's Bookstore application:
<render-kit>
<renderer>
<component-family>Area</component-family>
<renderer-type>DemoArea</renderer-type>
<renderer-class>
com.sun.bookstore6.renderers.AreaRenderer
</renderer-class>
<attribute>
<attribute-name>onmouseout</attribute-name>
<attribute-class>java.lang.String</attribute-class>
</attribute>
<attribute>
<attribute-name>onmouseover</attribute-name>
<attribute-class>java.lang.String</attribute-class>
</attribute>
<attribute>
<attribute-name>styleClass</attribute-name>
<attribute-class>java.lang.String</attribute-class>
</attribute>
</renderer>
...
The render-kit element represents a RenderKit implementation. If no render-kit-id is
specified, the default HTML render kit is assumed. The renderer element represents a
Renderer
implementation. By nesting the renderer element inside the render-kit element,
you are registering the renderer with the RenderKit implementation associated with the
render-kit
element.
The renderer-class is the fully qualified class name of the Renderer.
The component-family and renderer-type elements are used by a component to find
renderers that can render it. The component-family identifier must match that returned by the
component class's getFamily method. The component family represents a component or set of
components that a particular renderer can render. The renderer-type must match that
returned by the getRendererType method of the tag handler class.
Registering a Custom Renderer with a Render Kit
Chapter 14 · Configuring JavaServer Faces Applications
455