Java Reference
In-Depth Information
If we had been using dynamic navigation (and, of course, if there were more than two
JSP pages in the application), we would simply drag the connector from welcomeJSF.
jsp to another page to create a different navigation case based on the value of the
managed bean method executed when clicking the page's command button.
The NetBeans PageFlow editor updates our application's faces-config.xml behind
the scenes. It adds a <navigation-rule> element to it.
<navigation-rule>
<from-view-id>/welcomeJSF.jsp</from-view-id>
<navigation-case>
<from-outcome>submit</from-outcome>
<to-view-id>/confirmation.jsp</to-view-id>
</navigation-case>
</navigation-rule>
The <from-view-id> element is the name of the JSP originating the navigation. It is
the JSP we drag from in the PageFlow editor to create the navigation case. The value
of the <to-view-id> element is the destination page. It is generated from the JSP we
drag the navigation case to in the PageFlow editor. The value of the <from-outcome>
element is the name of the navigation case outcome in the PageFlow editor.
If we had been using dynamic navigation, we would have separate <navigation-
case> elements for each possible return value of the managed bean method bound
to the page's command button, the body of the <from-outcome> element of each
navigation case would be one possible return value, and the body of the <to-view-
id> would be the page we would navigate to for that particular navigation case.
Notice that the value of the <from-view-id> element starts with a
forward slash ( / ). A common mistake when setting up JSF navigation
is to forget this initial tag. When this happens, JSF will fail to find the
destination JSP and will simply redisplay the page that initiated the
navigation. Using NetBean's PageFlow editor prevents us from making
that mistake.
After setting up our navigation case, we now need to modify the generated
confirmation.jsp so that it displays the values in our managed bean.
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<html>
 
Search WWH ::




Custom Search