Page Navigation using Sun Java Studio Creator 2 - Navigating between three pages: example 2
(Page 4 of 4 )
The process of navigating between more than two pages follows in exactly the same way as what was described for two pages. The next picture shows the design view of navigation between three pages, HomePage.jsp, Tutorials.jsp, WebSites.jsp. These pages are also in the same project. Each of the pages have two hyperlinks that connect to two other pages as shown.

The <faces-config/> is just one file which includes all the navigation rules for the project. In this case it includes the rules for both the two page example as well as the three page example as shown. The code in blue is for navigating the pages in the three pages HomePage.jsp, Tutorials.jsp and Websites.jsp. The code in green is for the two pages NewYork.jsp and Chicago.jsp. There are no links between the two sets of pages.
<?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>/HomePage.jsp</from-view-id>
<navigation-case>
<from-outcome>case1</from-outcome>
<to-view-id>/Tutorials.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>case2</from-outcome>
<to-view-id>/Websites.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/Tutorials.jsp</from-view-id>
<navigation-case>
<from-outcome>case1</from-outcome>
<to-view-id>/HomePage.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>case2</from-outcome>
<to-view-id>/Websites.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/Websites.jsp</from-view-id>
<navigation-case>
<from-outcome>case1</from-outcome>
<to-view-id>/HomePage.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>case2</from-outcome>
<to-view-id>/Tutorials.jsp</to-view-id>
</navigation-case>
</navigation-rule> <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>
<navigation-rule>
<from-view-id>/Chicago.jsp</from-view-id>
<navigation-case>
<from-outcome>case1</from-outcome>
<to-view-id>/NewYork.jsp</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
Instead of beginning with the pages all ready to start with, you may begin adding pages from inside the Page Navigation designer interface by right clicking in an empty area to create a page. Also the designer is quite user friendly. You can highlight a link by clicking it in the designer and looking at its properties as shown. In a simple diagram like this it is obvious, but if there are a large number of links this will be a necessary feature.

Summary
Page navigation is really effortless with Sun Java Studio Creator 2. This article described page navigation for a web project with two examples. The designer is meant for only navigating to Java server pages and is not intended for HTML pages and page fragments. Navigation is truly codeless once it is correctly configured.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |