Model View Controller Application: View

Finally, you will continue with the MVC application case study Airline Ticket Booking System. Per your design, the JavaServer Pages form the View of the MVC architecture. On Day 4, "Advanced Servlet Techniques," you already built the Controller servlet for the application. For the View of the application you will build the JavaServer Pages. These JSPs will be the User Interface for the Airline Ticket Booking System. The JSPs in the View layer will receive the response data from the Controller servlet via the MVCValueObject.

Look at the different JSPs that make up the View for the Airline Ticket Booking System. The JSPs have a virtual mapping in the web.xml file; that is, when the user types out this JSP's virtual name in the address bar, the actual JSP is called. The first JSP that the user will see is the CheckAvailFlightsPage.jsp. The virtual name for this jsp is "Welcome". The JSP captures the user's search criteria. An option for the user to view his profile is available on this page.

Clicking the option of viewing a profile takes the user to a login page. Login.jsp has the virtual name "login".

If the user does not have an ID, the user needs to register with the Airline Ticket Booking System by selecting to add their user profile details to the application, using the RegisterUserProfilePage.jsp, virtual name "register_profile".

After logging in, the user can view his profile on the ViewUserProfilePage.jsp with virtual name "view_profile". Here, the user can go back to the first page (the search page). If the user enters his search criteria on the search page, he is brought to a page called ViewAvailFlightsPage.jsp with a virtual name "view_avail_flights". The user gets to make a selection from the available flights here and then can click a button called "Book Ticket." When the user clicks this button, the user is taken to the login page again, where after logging in, he is taken to the confirmation page called ConfirmFlightDetails.jsp with the virtual name "confirmation_page". When the user clicks the Confirm button, he is shown the Message.jsp page with virtual name "message_page", with the ticket number displayed. In case the user does not have a login ID, he can register first and then is shown the confirmation page.

You will also be using the JSP tag libraries provided by WebLogic Server for performing form data validations and caching data between pages. These are the same tag libraries that you studied in the section "WebLogic's JSP Tag Library."

Table 6.1 shows the entire list of JavaServer Pages that will form the View layer of the Airline Ticket Booking System MVC application.

Table 6.1. JavaServer Pages for the Airline Ticket Booking System MVC Application

JSP Filename

Remarks

CheckAvailFlights.jsp

Screen where the user performs a search for available flights based oncertain criteria. This is the default homepage for the MVC application and the starting point for your application.

ViewAvailFlightsPage.jsp

The results of the search for available flights are displayed in this JSP.

Login.jsp

Sign-on screen for a user registered with the MVC application. A registereduser can perform additional functions, such as booking tickets, viewing previous bookings, and so on.

RegisterUserProfilePage.jsp

The user enters profile information for registering with the application using this JSP.

ConfirmFlightDetails.jsp

Screen that displays the details of the flight selected by the user and prompts the user for confirmation

ViewUserProfile.jsp

Screen that displays the details of the logged-in user's profile.

Message.jsp

Used by the MVC application to display the results of confirming a booking. It normally displays the newly issued ticket number.

Error.jsp

Used by the MVC application to display error messages.

Take a look at Figure 6.7 to understand the interactions between the browser and the Controller servlet. This will help you understand which JavaServer Pages are mapped to which actions in the Controller servlet and the sequence in which the JavaServer Pages will be displayed during the execution of the MVC application.

Figure 6.7. Sequence diagram showing the details of the View layer of the MVC application.

graphics/06fig07.jpg

Finally, see the code listing in Appendix C, "Source Code for MVC Application."



Sams Teach Yourself BEA WebLogic Server 7. 0 in 21 Days
Sams Teach Yourself BEA WebLogic Server 7.0 in 21 Days
ISBN: 0672324334
EAN: 2147483647
Year: 2002
Pages: 339

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net