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.

Coffee Break Server<br />

1040<br />

<br />

With the required attribute set to true, the <strong>Java</strong>Server Faces implementation will check<br />

whether the user entered something in the First Name field.<br />

<strong>The</strong> email component has a custom validator registered on it. Here is the tag corresponding to<br />

the email component:<br />

<br />

<strong>The</strong> validator attribute refers to the validateEmail method on the CheckoutFormBean class.<br />

This method ensures that the value the user enters in the email field contains an @ character.<br />

If the validation does not succeed, the checkoutForm is re-rendered, with error notifications in<br />

each invalid field. If the validation succeeds, checkoutFormBean submits suborders to each<br />

supplier and stores the result in the request-scoped OrderConfirmations <strong>Java</strong>Beans<br />

component and control is passed to the checkoutAck page.<br />

<strong>The</strong> checkoutAck Page<br />

checkoutAck simply displays the contents of the OrderConfirmations <strong>Java</strong>Beans component,<br />

which is a list of the suborders constituting an order and the ship dates of each suborder. This<br />

page also uses a UIData component. Again, the number of coffees the customer ordered is not<br />

known before runtime. <strong>The</strong> UIData component dynamically adds rows to accommodate the<br />

order.<br />

<strong>The</strong> checkoutAck.jsp page also makes use of a custom converter that converts the shipping<br />

date into an XMLGregorianCalendar type:<br />

<br />

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

Saved successfully!

Ooh no, something went wrong!