background image

Coffee Break Server

<< The SOAPBodyElement Class | The checkoutForm Page >>
<< The SOAPBodyElement Class | The checkoutForm Page >>

Coffee Break Server

Coffee Break Server
The Coffee Break server uses JavaServer Faces technology to build its user interface. The JSP
pages use JavaServer Faces UI component tags to represent widgets, such as text fields and
tables. All the JSP pages use preludes and codas to achieve a common look and feel among the
HTML pages, and many of the JSTL custom tags discussed in
Chapter 7, "JavaServer Pages
Standard Tag Library."
The Coffee Break server implementation is organized along the Model-View-Controller design
pattern. A FacesServlet instance (included with the JavaServer Faces API) acts as the
controller. It examines the request URL, creates and initializes model JavaBeans components,
and dispatches requests to view JSP pages. The JavaBeans components contain the business
logic for the application; they call the web services and perform computations on the data
returned from the services. The JSP pages format the data stored in the JavaBeans components.
The mapping between JavaBeans components and pages is summarized in
Table 36­1
.
TABLE 36­1
Model and View Components
Function
JSP Page
JavaBeans Component
Update order data
orderForm
ShoppingCart
Update delivery and billing data
checkoutForm
CheckoutFormBean
Display order confirmation
checkoutAck
OrderConfirmations
JSP Pages
The JSP pages are as follows:
"The orderForm Page" on page 1046
"The checkoutForm Page" on page 1047
"The checkoutAck Page" on page 1048
The orderForm Page
orderForm
displays the current contents of the shopping cart. The first time the page is
requested, the quantities of all the coffees are 0 (zero). Each time the customer changes the
coffee amounts and clicks the Update button, the request is posted back to orderForm.
The CoffeeBreakBean bean component updates the values in the shopping cart, which are then
redisplayed by orderForm. When the order is complete, the customer proceeds to the
checkoutForm
page by clicking the Checkout button.
The table of coffees displayed on the orderForm is rendered using one of the JavaServer Faces
component tags, dataTable. Here is part of the dataTable tag from orderForm:
Coffee Break Server
The Java EE 5 Tutorial · September 2007
1046