Page Navigation using Sun Java Studio Creator 2 - Navigating to Chicago.jsp by clicking a link on the NewYork.jsp
(Page 2 of 4 )
From the Palette drag and drop a hyperlink control to the NewYork.jsp page. If you right click this hyperlink you will get a drop-down menu from which you can do a lot of things. You can edit the text, the JSP source, and so forth. For this example the text was edited to read "Go to Chicago."

Now go back to the Page Navigation designer and click on the NewYork.jsp page. The size of the page increases and shows the hyperlink you created in the previous paragraph as shown.

Now click on the hyperlink in NewYork.jsp in the designer of the Page Navigation (in the previous picture) and drag the line that follows the mouse towards the Chicago.jsp page as shown.

When you terminate the line on Chicago.jsp, the design view appears as shown. This ensures that when you click on the link in NewYork.jsp you will bring up the Chicago.jsp page in the browser.

This design information transforms to the XML navigation definition as shown in the Source View of Page Navigation as shown. The file is pretty intuitive about what it does.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD
JavaServer Faces Config 1.1//EN"
"http://java.sun.com/dtd/web-
facesconfig_1_1.dtd">
<faces-config>
<navigation-rule>
<from-view-id>/NewYork.jsp</from-view-id>
<navigation-case>
<from-outcome>case1</from-outcome>
<to-view-id>/Chicago.jsp</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
The root element of this XML configuration file is <faces-config/> and there can be any number of <navigation-rule/> nodes. Each node consists of a <navigation-case/> defining the navigation. In this case, case1 defines going from NewYork.jsp and navigating to Chicago.jsp.
Next: Build and run the project >>
More Java Articles
More By Jayaram Krishnaswamy