|
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
Rendererobjects that can render the component in different ways to the client supported by the render kit. For example, the standardUISelectOnecomponent class defines a component that allows a user to select one item from a group of items. This component can be rendered using theListboxrenderer, theMenurenderer, or theRadiorenderer. Each renderer produces a different appearance for the component. TheListboxrenderer renders a menu that displays all possible values. TheMenurenderer renders a subset of all possible values. TheRadiorenderer 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-kitelement of the application configuration resource file. Here is the configuration of theAreaRendererfrom 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-kitelement represents aRenderKitimplementation. If norender-kit-idis specified, the default HTML render kit is assumed. Therendererelement represents aRendererimplementation. By nesting therendererelement inside therender-kitelement, you are registering the renderer with theRenderKitassociated with therender-kitelement.The
renderer-typewill be used by the tag handler, as explained in the next section. Therenderer-classis the fully qualified class name of theRenderer.Each of the
attributetags 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 theRenderersupports.The
supported-component-classtag 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.