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.

<strong>The</strong> value attributes of the area tags refer to the beans in the application scope, as shown in this<br />

area tag from chooselocale.jsp:<br />

<br />

To reference the ImageArea model object bean values from the component class, you<br />

implement a getValue method in the component class. This method calls super.getValue.<br />

<strong>The</strong> superclass of<br />

tut-install/javaeetutorial5/examples/web/bookstore6/src/java/com/sun/bookstore6/componen<br />

UIOutput, has a getValue method that does the work of finding the ImageArea object<br />

associated with AreaComponent. <strong>The</strong> AreaRenderer class, which needs to render the alt, shape,<br />

and coords values from the ImageArea object, calls the getValue method of AreaComponent to<br />

retrieve the ImageArea object.<br />

ImageArea iarea = (ImageArea) area.getValue();<br />

ImageArea is only a simple bean, so you can access the shape, coordinates, and alternative text<br />

values by calling the appropriate accessor methods of ImageArea. “Creating the Renderer Class”<br />

on page 425 explains how to do this in the AreaRenderer class.<br />

Summary of the Application Classes<br />

Table 13–2 summarizes all the classes needed to implement the image map component.<br />

TABLE 13–2 Image Map Classes<br />

Class Function<br />

AreaSelectedEvent <strong>The</strong> ActionEvent indicating that an AreaComponent from the MapComponent has been<br />

selected.<br />

AreaTag <strong>The</strong> tag handler that implements the area custom tag.<br />

MapTag <strong>The</strong> tag handler that implements the map custom tag.<br />

AreaComponent <strong>The</strong> class that defines AreaComponent, which corresponds to the area custom tag.<br />

MapComponent <strong>The</strong> class that defines MapComponent, which corresponds to the map custom tag.<br />

AreaRenderer This Renderer performs the delegated rendering for AreaComponent.<br />

ImageArea <strong>The</strong> bean that stores the shape and coordinates of the hotspots.<br />

LocaleBean <strong>The</strong> backing bean for the chooselocale.jsp page.<br />

Understanding the Image Map Example<br />

Chapter 13 • Creating Custom UI Components 415

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

Saved successfully!

Ooh no, something went wrong!