Download
FAQ History |
API
Search Feedback |
Registering a Custom Renderer with a Render Kit
For every UI component that a render kit supports, the render kit defines a set of
Renderer
objects that can render the component in different ways to the client supported by the render kit. For example, the standardUISelectOne
component class defines a component that allows a user to select one item from a group of items. This component can be rendered using theListbox
renderer, theMenu
renderer, or theRadio
renderer. Each renderer produces a different appearance for the component. TheListbox
renderer renders a menu that displays all possible values. TheMenu
renderer renders a subset of all possible values. TheRadio
renderer renders a set of radio buttons.When the application developer creates a custom renderer, as described in Delegating Rendering to a Renderer, you must register it using the appropriate render kit. Because the image map application implements an HTML image map,
AreaRenderer
(as well asMapRenderer
) 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 theAreaRenderer
from the Duke's Bookstore application:<render-kit> <renderer> <renderer-type>DemoArea</renderer-type> <renderer-class> renderkit.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> <supported-component-class> <component-class> components.AreaComponent </component-class> </supported-component-class> </renderer> ...The
render-kit
element represents aRenderKit
implementation. If norender-kit-id
is specified, the default HTML render kit is assumed. Therenderer
element represents aRenderer
implementation. By nesting therenderer
element inside therender-kit
element, you are registering the renderer with theRenderKit
associated with therender-kit
element.The
renderer-type
will be used by the tag handler, as explained in the next section. Therenderer-class
is the fully qualified class name of theRenderer
.Each of the
attribute
tags specifies a render-dependent attribute and its type. The attribute element doesn't affect the runtime execution of your application. Instead, it provides information to tools about the attributes theRenderer
supports.The
supported-component-class
tag specifies the UI component classes that delegate their rendering to this renderer.
Download
FAQ History |
API
Search Feedback |
All of the material in The J2EE(TM) 1.4 Tutorial is copyright-protected and may not be published in other works without express written permission from Sun Microsystems.