Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
| 29.3 | (Registration Form Modification) Modify the WebComponents application to add functionality to the Register button. When the user clicks Register, validate all input fields to make sure the user has filled out the form completely and entered a valid email address and phone number. Then, display a message indicating successful registration and show the user’s registration information at the bottom of the page. (This is similar to the example in Section 29.7.) You’ll need to create an appropriate bean class to store the user’s registration information. |
| 29.4 | (Shopping Cart Application) Using the techniques you learned in Section 29.8.2, create a simple shopping cart application. Display a list of books as an h:selectOneRadio element. When the user submits the form, store the user’s selection in a @SessionScoped managed bean. Allow the user to return to the list of books and make additional selections. Provide a link to view the shopping cart. On the shopping cart page, display the list of selections the user made, the price of each book and the total of all books in the cart. |
| 29.5 | (Guestbook Application) In Section 29.8.2, you used an @SessionScoped managed bean to maintain an individual user’s selections. JSF also provides the @ApplicationScoped annotation for managed beans that should be shared among all users of a JSF app. For this exercise, create an @ApplicationScoped GuestbookBean that maintains a List of GuestbookEntry objects. The application should provide a form, similar to the one in Fig. 29.16 that enables a user to enter a name, an email address and a message. When the user submits the form, the GuestbookBean should create a GuestbookEntry object containing the submitted values and insert it at the beginning of the List of GuestbookEntry objects—this places the most recent entry first. The GuestbookBean should also provide a read-only property that returns the List of GuestbookEntry objects. The page should use a ui:repeat element to display all of the items in the List so the user can see all the guestbook entries so far. [Note: In the next chapter, you’ll implement a similar exercise that stores this information in a database.] |