10 - Planning Navigation and Page Flow
10 - Planning Navigation and Page Flow
10 - Planning Navigation and Page Flow
<body>
<form action="myNewPage.html">
<button type="button"/>
</form>
<a href="http://myNewPage.html">
Go To My New Page
</a></body>
firstPage
myNewPage
Button success
firstPage.jsp myNewPage.jsp
Example:
– /login.jsp navigation rule with two cases
– login.jsp managed by the login backing bean
– loginAction() is the method that returns
success or failure:
– If the method returns
success, forward the user to
/successPage.jsp.
– If the method returns
failure, forward the
user to /failurePage.jsp.
…
<navigation-rule>
<from-view-id>/login.jsp</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/successPage.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>failure</from-outcome>
<to-view-id>/failurePage.jsp</to-view-id>
</navigation-case>
</navigation-rule>
…
• <navigation-rule> • <from-action>
• <from-view-id> • <from-outcome>
• <navigation-case> • <to-view-id>
<navigation-rule>
<from-view-id>/SREdit.jspx</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/SRSearch.jspx</to-view-id>
</navigation-case>
</navigation-rule>
loginAction Success
success.jsp
login.jsp
Failure
failure.jsp
<h:InputText value="#{Login.userId}"/>
<h:InputSecret value="#{Login.password}"/>
login.jsp
login.jsp
Entry in faces-config.xml:
<managed-bean>
<managed-bean-name> UserInfo </managed-bean-name>
<managed-bean-class> org.srdemo.view.backing.UserInfo
</managed-bean-class>
<managed-bean-scope> session </managed-bean-scope>
</managed-bean>
• Definition:
<managed-bean>
<managed-bean-name>userbean</managed-bean-name>
<managed-bean-class>com.oracle.sample.User</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
• Usage on a page:
<h:inputText value="#{userbean.name}"/>
• Usage in code:
Application app =
FacesContext.getCurrentInstance().getApplication();
ValueBinding bind = app.createValueBinding("#{userbean}");
User user = (User)bind.getValue(ctx);
none Yes No No No
• Possible values:
– Null
– Literal string
– Lists and maps
– Value binding expression (EL)
Literal string:
<managed-bean> …
<managed-property>
<property-name>label</property-name>
<value>Hello World</value>
</managed-property>
Populating a list:
<managed-bean>
…
<managed-property>
<property-name>bookmarks</property-name>
<list-entries>
<value>http://otn.oracle.com/products/jev</value>
<value>http://otn.oracle.com/products/ias</value>
</list-entries>
</managed-property>
…
binding="#{SuccessPage.outputText1}"
id="outputText1"
/> …