background image

The RetailPriceList JavaBeans Component

<< JavaBeans Components | The CoffeeBreakBean JavaBeans Component >>
<< JavaBeans Components | The CoffeeBreakBean JavaBeans Component >>

The RetailPriceList JavaBeans Component

"The CoffeeBreakBean JavaBeans Component" on page 1050
The RetailPriceList JavaBeans Component
RetailPriceList
is a list of retail price items. A retail price item contains a coffee name, a
wholesale price per pound, a retail price per pound, and a supplier. This data is used for two
purposes: it contains the price list presented to the end user and is used by CheckoutFormBean
when it constructs the suborders dispatched to coffee suppliers.
RetailPriceList
first calls the URLHelper.getEndpointURL method to determine the JAX-WS
service endpoint. It then queries the JAX-WS service for a coffee price list. Finally it queries the
SAAJ service for a price list. The two price lists are combined and a retail price per pound is
determined by adding a markup of 35% to the wholesale prices.
The ShoppingCart JavaBeans Component
ShoppingCart
is a list of shopping cart items. A ShoppingCartItem contains a retail price item,
the number of pounds of that item, and the total price for that item.
The OrderConfirmations JavaBeans Component
OrderConfirmations
is a list of order confirmation objects. An OrderConfirmation contains
order and confirmation objects, as discussed in
"Service Implementation" on page 1031
.
The CheckoutFormBean JavaBeans Component
CheckoutFormBean
checks the completeness of information entered into checkoutForm. If the
information is incomplete, the bean populates error messages, and redisplays checkoutForm
with the error messages. If the information is complete, order requests are constructed from the
shopping cart and the information supplied to checkoutForm, and these orders are sent to each
supplier. As each confirmation is received, an order confirmation is created and added to
OrderConfirmations
.
Several of the tags on the checkoutForm page have their required attributes set to true. This
will cause the implementation to check whether the user enters values in these fields. The tag
corresponding to the email component registers a custom validator on the email component,
as explained in
"The checkoutForm Page" on page 1047
. The code that performs the validation
is the validateEmail method:
public void validateEmail(FacesContext context,
UIComponent toValidate, Object value) {
String message =
"";
String email = (String) value;
if (email.indexOf(
'@') == -1) {
((UIInput)toValidate).setValid(false);
message = CoffeeBreakBean.loadErrorMessage(context,
Coffee Break Server
Chapter 36 · The Coffee Break Application
1049