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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Understanding the Image Map Example<br />

Duke’s Bookstore includes a custom image map component on the chooselocale.jsp page.<br />

This image map displays a map of the world. When the user clicks one of a particular set of<br />

regions in the map, the application sets the locale on the UIViewRoot component of the current<br />

FacesContext to the language spoken in the selected region. <strong>The</strong> hotspots of the map are the<br />

United States, Spanish-speaking Central and South America, France, and Germany.<br />

Why Use <strong>Java</strong>Server FacesTechnology to Implement<br />

an Image Map?<br />

<strong>Java</strong>Server Faces technology is an ideal framework to use for implementing this kind of image<br />

map because it can perform the work that must be done on the server without requiring you to<br />

create a server-side image map.<br />

In general, client-side image maps are preferred over server-side image maps for several<br />

reasons. One reason is that the client-side image map allows the browser to provide immediate<br />

feedback when a user positions the mouse over a hotspot. Another reason is that client-side<br />

image maps perform better because they don’t require round-trips to the server. However, in<br />

some situations, your image map might need to access the server to retrieve data or to change<br />

the appearance of non-form controls, tasks that a client-side image map cannot do.<br />

Because the image map custom component uses <strong>Java</strong>Server Faces technology, it has the best of<br />

both styles of image maps: It can handle the parts of the application that need to be performed<br />

on the server, while allowing the other parts of the application to be performed on the client<br />

side.<br />

Understanding the Rendered HTML<br />

Here is an abbreviated version of the form part of the HTML page that the application needs to<br />

render:<br />

<br />

...<br />

<br />

<br />

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

Saved successfully!

Ooh no, something went wrong!