In this lab, you will complete a Web app that is a little larger than the To Do list app in the previous lab. We will use Java Server Faces on the front-end, and managed beans for the backend.
In the laboratory sessions, we will be using this online waiting list. Please sign in and add yourself to the list when you need help:
http://www.waglys.com/LxXLKh (Links to an external site.)
Step One - Setup
Download the file library.zip. Extract it to a directory, then open it as a NetBeans project. Try to compile and run it. You should see a screen like the screenshot below. The Authors page should also work, but the other pages should be deactivated for now. If this does not work, please get help with this before going any farther.
Step Two - Addresses
First, notice in the Authors page that addresses are not being printed in a very nice way. Fix this!
Step Three - Books
Write the Books page and the BookCatalogue class. The structure will be very similar to the Authors page; however, you may decide to change some things (for example, since the Genre must be one of a finite number of choices, you might make it a drop-down menu and not a text box).
Don't rush this. It is possible to complete this by copy-and-pasting the Author code, search-and-replace Author to Book, then fix the errors one by one. However, there is no point to this lab if you do not understand how the code works. I strongly recommend you get the features working one by one (list, then add, then edit, then delete), adding backend code only when you need it. Reuse code from Author (that's why it's there), but I suggest you type the code in yourself instead of copying-and-pasting.
Step Four - Linking the Two
Now, we want to say that every book has an author. Add this ability, plus the ability to click on an author in the Authors page and see the list of all the books they have written.
To do this, you will need a way for the user to enter an author. To pass this lab, it is sufficient to implement this feature as follows: the user must enter the author's name in a text box as (Surname, First name), and it must be an exact match. (We assume we do not have two authors with the same name.)
This is not ideal, and you may think about a better user interface - see the Optional part below
Here are some features you might want to add to the app.
- A better interface for entering the author of a book. For example, the user enters a surname and - if there is more than one author with that surname - a list of all those authors is displayed, and the user selects one.
- Write a good looking About and Contact page.
- Have a look at the PrimeFaces library. Use one (or more) of its components to improve the app.