10.12.2012 Views

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Using Custom Objects<br />

In the rendered HTML page, the onmouseover, onmouseout, and onclick attributes define<br />

which <strong>Java</strong>Script code is executed when these events occur. When the user moves the mouse<br />

over a region, the onmouseover function associated with the region displays the map with that<br />

region highlighted. When the user moves the mouse out of a region, the onmouseout function<br />

redisplays the original image. When the user clicks a region, the onclick function sets the value<br />

of a hidden input tag to the ID of the selected area and submits the page.<br />

When the custom renderer renders these attributes in HTML, it also renders the <strong>Java</strong>Script<br />

code. <strong>The</strong> custom renderer also renders the entire onclick attribute rather than let the page<br />

author set it.<br />

<strong>The</strong> custom renderer that renders the map tag also renders a hidden input component that<br />

holds the current area. <strong>The</strong> server-side objects retrieve the value of the hidden input field and<br />

set the locale in the FacesContext instance according to which region was selected.<br />

Chapter 13, “Creating Custom UI Components,” describes the custom tags in more detail and<br />

also explains how to create the custom image map components, renderers, and tags.<br />

Chapter 11 • Using <strong>Java</strong>Server FacesTechnology in JSP Pages 375

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!