The cardemo Example
This chapter primarily uses the cardemo example to illustrate the basic concepts of JavaServer Faces technology. This example emulates on online car dealership, with features such as price updating, car option packaging, a custom converter, a custom validator, and an image map custom component. Table 21-2 lists all of the files used in this example, except for the image and properties files.
Table 21-2 Example Files
File
|
Function
|
ImageMap.jsp
|
The first page that allows you to select a locale
|
Storefront.jsp
|
Shows the cars available
|
more.jsp
|
Allows you to choose the options for a particular car
|
buy.jsp
|
Shows the options currently chosen for a particular car
|
Customer.jsp
|
Allows you to enter your personal information so that you can order the car
|
Thanks.jsp
|
The final page that thanks you for ordering the car
|
error.jsp
|
A page that displays an error message
|
CarActionListener.java
|
The ActionListener that handles the car packaging dependencies on more.jsp
|
CreditCardConverter.java
|
Defines a custom Converter
|
FormatValidator.java
|
Defines a custom Validator
|
CurrentOptionServerBean.java
|
Represents the model for the currently-chosen car
|
CustomerBean.java
|
Represents the model for the customer information
|
ImageMapEventHandler.java
|
Handles the ActionEvent caused by clicking on the image map
|
PackageValueChanged.java
|
Handles the event of selecting options on more.jsp and updates the price of the car
|
The cardemo
also uses a set of model objects, custom components, renderers, and tags, as shown in Table 21-3. These files are located in the examples/components
directory of your download.
Table 21-3 Model Objects, Custom Components, Renderers, and Tags Used by cardemo
File
|
Function
|
AreaRenderer
|
This Renderer performs the delegated rendering for the UIArea component
|
AreaTag
|
The tag handler that implements the area custom tag
|
ImageArea
|
The model object that stores the shape and coordinates of the hot spots
|
MapTag
|
The tag handler that implements the map custom tag
|
UIArea
|
The class that defines the UIArea component, corresponding to the area custom tag
|
UIMap
|
The class that defines the UIMap component, corresponding to the map custom tag
|
Figure 21-1 illustrates the page flow for the cardemo
application starting at Storefront.jsp.
.
Figure 21-1 Page Flow for cardemo