Java Reference
In-Depth Information
Configuring Model Data
In a JavaServer Faces application, data such as the coordinates of a hotspot of an image
map is retrieved from the
value
attribute through a bean. However, the shape and co-
ordinates of a hotspot should be defined together because the coordinates are interpreted
differently depending on what shape the hotspot is. Because a component's value can be
bound only to one property, the
value
attribute cannot refer to both the shape and the
coordinates.
To solve this problem, the application encapsulates all of this information in a set of
ImageArea
objects. These objects are initialized into application scope by the managed
bean creation facility (see “Managed Beans in JavaServer Faces Technology” in
The Java
EE 6 Tutorial: Basic Concepts
). Here is part of the managed bean declaration for the
ImageArea
bean corresponding to the South America hotspot:
<managed-bean eager="true">
...
<managed-bean-name> Book201 </managed-bean-name>
<managed-bean-class> dukesbookstore.model.ImageArea /managed-
bean-class>
<managed-bean-scope> application </managed-bean-scope>
<managed-property>
...
<property-name>shape</property-name>
<value>rect</value>
</managed-property>
<managed-property>
...
<property-name>alt</property-name>
<value>Duke</value>
</managed-property>
<managed-property>
...
<property-name>coords</property-name>
<value>67,23,212,268</value>
</managed-property>
</managed-bean>
For more information on initializing managed beans with the managed bean creation fa-
cility, see the section “
Application Configuration Resource File
” on page
144
.
The
value
attributes of the
bookstore:area
tags refer to the beans in the application
scope, as shown in this
bookstore:area
tag from
index.xhtml
: