background image

The Custom Renderer

<< Using a Custom Component | Developing with JavaServer Faces Technology >>
<< Using a Custom Component | Developing with JavaServer Faces Technology >>

The Custom Renderer

In the rendered HTML page, the onmouseover, onmouseout, and onclick attributes define
which JavaScript code is executed when these events occur. When the user moves the mouse
over a region, the onmouseover function associated with the region displays the map with that
region highlighted. When the user moves the mouse out of a region, the onmouseout function
redisplays the original image. When the user clicks a region, the onclick function sets the value
of a hidden input tag to the ID of the selected area and submits the page.
When the custom renderer renders these attributes in HTML, it also renders the JavaScript
code. The custom renderer also renders the entire onclick attribute rather than let the page
author set it.
The custom renderer that renders the map tag also renders a hidden input component that
holds the current area. The server-side objects retrieve the value of the hidden input field and
set the locale in the FacesContext instance according to which region was selected.
Chapter 13, "Creating Custom UI Components"
describes the custom tags in more detail and
also explains how to create the custom image map components, renderers, and tags.
Using Custom Objects
Chapter 11 · Using JavaServer Faces Technology in JSP Pages
377