background image

Specifying the Component Family

<< The UIComponentBase | Performing Encoding >>
<< The UIComponentBase | Performing Encoding >>

Specifying the Component Family

The rendering of the map and input tags is performed by
tut-install/javaeetutorial5/examples/web/bookstore6/src/java/com/sun/bookstore6/renderers/MapRenderer.j
but MapComponent delegates this rendering to MapRenderer.
AreaComponent
is bound to a bean that stores the shape and coordinates of the region of the
image map. You'll see how all this data is accessed through the value expression in
"Creating
the Renderer Class" on page 427
. The behavior of AreaComponent consists of the following
Retrieving the shape and coordinate data from the bean
Setting the value of the hidden tag to the id of this component
Rendering the area tag, including the JavaScript for the onmouseover, onmouseout, and
onclick
functions
Although these tasks are actually performed by AreaRenderer, AreaComponent must delegate
the tasks to AreaRenderer. See
"Delegating Rendering to a Renderer" on page 427
for more
information.
The rest of this section describes the tasks that MapComponent performs as well as the encoding
and decoding that it delegates to MapRenderer.
"Handling Events for Custom Components" on
page 429
details how MapComponent handles events.
Specifying the Component Family
If your custom component class delegates rendering, it needs to override the getFamily
method of UIComponent to return the identifier of a component family, which is used to refer to
a component or set of components that can be rendered by a renderer or set of renderers. The
component family is used along with the renderer type to look up renderers that can render the
component.
Because MapComponent delegates its rendering, it overrides the getFamily method:
public String getFamily() {
return (
"Map");
}
The component family identifier, Map, must match that defined by the component-family
elements included in the component and renderer configurations in the application
configuration resource file.
"Registering a Custom Renderer with a Render Kit" on page 455
explains how to define the component family in the renderer configuration.
"Registering a
Custom Component" on page 457
explains how to define the component family in the
component configuration.
Creating Custom Component Classes
Chapter 13 · Creating Custom UI Components
421