Sunday, June 15, 2008

JSF navigation

Sample 1
<navigation-rule>
<from-view-id>/pages/index.jsp</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/pages/welcome.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>failure</from-outcome>
<to-view-id>/pages/index.jsp</to-view-id>
</navigation-case>
</navigation-rule>

The value of "from-outcome" should be consistent with the return value of any control method.
public String actionMethod(){
...
return "success"
}

Or the value of action in jsf tag like CommandButton or CommandLink.
<h:commandButton action="success" value="Go to success page" immediate="true"/>

Sample 2
<navigation-rule>
<from-view-id>/pages/index.jsp</from-view-id>
<navigation-case>
<from-action>#{user.verify}</from-action>
<from-outcome>success</from-outcome>
<to-view-id>/pages/welcome.jsp</to-view-id>
</navigation-case>
....
</navigation-rule>
This navigation rule need
- the method "user.verify()" was triggered.
- the return value of "user.verify()" was "success".
Then it would navigate to page "/pages/welcome.jsp"


Sample 3
<navigation-rule>
<from-view-id>/pages/index.jsp</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/pages/welcome.jsp</to-view-id>
<redirect/>
</navigation-case>
....
</navigation-rule>
The navigation rule will be applied to those requests coming from "/pages/index.jsp"

Wildcard is allowed here.
<navigation-rule>
<from-view-id>/admin/*</from-view-id>
<navigation-case>
<from-action>#{user.verify}</from-action>
<from-outcome>success</from-outcome>
<to-view-id>/pages/welcome.jsp</to-view-id>
</navigation-case>
....
</navigation-rule>

No comments:

Post a Comment