Set Up the Navigation Rules for Existing Web Pages

Một phần của tài liệu practical database aprogramming with java (Trang 582 - 585)

JAVA RUNTIME OBJECTS METHOD

8.6 BUILD JAVA WEB PROJECT TO ACCESS AND MANIPULATE ORACLE DATABASE

8.6.7 Set Up the Navigation Rules for Existing Web Pages

Figure 8.128. The codes for the ErrorPage.jsp fi le.

<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>

<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">

<f:view>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

<title>JSP Page</title>

</head>

<body>

<h1><h:outputText value="Some error occurred..."/></h1>

</body>

</html>

</f:view>

A

c08.indd 708

c08.indd 708 7/20/2011 11:12:35 AM7/20/2011 11:12:35 AM

www.traintelco.com

tion rules. In Section 5.3.5.12 in Chapter 5 , we have provided a detailed discussion about this confi guration fi le. Refer to that section to get more details for this fi le.

The operational navigation rule is: if the login process is successful, the next page,

SelectionPage.jsp , should be displayed to allow users to select different item from that page to perform related data query operations. Otherwise, if the login process has failed, the ErrorPage.jsp should be displayed to indicate this situation.

Now, let ’ s use this confi guration fi le to set up the navigation rules for our existing pages. Perform the following operations to set up the navigation rules for our existing pages:

1. Expand the Confi guration Files node that is under our project node JavaWebDBJSPOracle from the Projects window and double click on the fi le faces - confi g.xml to open it.

2. Click on the PageFlow button on the top of this opened fi le to display the fl ow of the web pages built in this project, as shown in Figure 8.129 .

3. Move your cursor to the starting arrow location as shown in Figure 8.129 until a square appears in the LogInPage.jsp page object. Then click on this square and drag this stating arrow and point to and stop at the center of the SelectionPage.jsp , as shown in Figure 8.129 - 1. A navigation link is established with the default name case1 , as shown in Figure 8.129 .

4. Double click on the default navigation link case1 and change its name to SELECTION . 5. Perform a similar operation to create another navigation link from the LogInPage.jsp to

the ErrorPage.jsp , as shown in Figure 8.129 - 2.

6. Double click on the new established link and change its name to ERROR . Your fi nished PageFlow view of two JSF page objects should match the one that is shown in Figure 8.130 . Now if you click on the XML button to open the XML view of this faces - confi g.

xml fi le, you can fi nd that the navigation rules shown in Figure 8.130 have been added into this fi le. The new added codes have been shown in steps A , B , and C in Figure 8.131 .

Figure 8.129. The opened PageFlow view of the faces - confi g.xml fi le.

1. Drag the starting arrow and stop at the center of the SelectionPage.jsp

2. Drag the starting arrow and stop at the center of the ErrorPage.jsp

Figure 8.130. The fi nished PageFlow view of the JSF page objects.

Figure 8.131. The XML view of the faces - confi g.xml fi le.

A B C D

c08.indd 710

c08.indd 710 7/20/2011 11:12:35 AM7/20/2011 11:12:35 AM

www.traintelco.com

Let ’ s have a closer look at this piece of newly created codes to see how it works.

A. Our source page, LogInPage.jsp , is added into the <from - view - id > tag that is located under the <navigation - rule > tag to indicate that this is the starting page.

B. Our next page for the login success processing, which is represented by a case String

SELECTION , is added into the <from - outcome > tag.

C. Our next page SelectionPage.jsp has been added into the <to - view - id > tag to indi- cate that this is our destination page if the login is successful.

D. The ERROR String represented our ErrorPage.jsp is added into another <from - outcome > tag with the ErrorPage.jsp as the content of the <to - view - id > tag.

Now that we have set up the navigation rules for our pages, next, let ’ s continue to build other pages and beans to perform the desired data queries. First, let ’ s handle the data query from the Faculty table in our sample database.

Một phần của tài liệu practical database aprogramming with java (Trang 582 - 585)

Tải bản đầy đủ (PDF)

(791 trang)