Wiki
Clone wikiOracle JSF Expert 1Z0-896 / faces-config.xml navigation rules
Navigation elements syntax
<navigation-rule> <description></description> <display-name></display-name> <icon></icon> <from-view-id></from-view-id> <navigation-case> <description></description> <display-name></display-name> <icon></icon> <from-action></from-action> <from-outcome></from-outcome> <if></if> <to-view-id></to-view-id> <redirect/> </navigation-case> </navigation-rule>
Redirect with view params
<navigation-rule> <from-view-id>/A.xhtml</from-view-id> <navigation-case> <from-outcome>B</from-outcome> <to-view-id>/B.xhtml</to-view-id> <redirect include-view-params=true> <view-param> <name>q</name> <value>#{quizBean.currentProblem + 1}</value> </view-param> </redirect> <navigation-case> </navigation-rule>
Wildcards in from-view-id
<navigation-rule> <from-view-id>/secure/*</from-view-id> <navigation-case> ... </navigation-case> </navigation-rule>
from-action example
<navigation-case> <from-action>#{quizBean.answerAction}</from-action> <from-outcome>again</from-outcome> <to-view-id>/again.xhtml</to-view-id> </navigation-case> <navigation-case> <from-action>#{quizBean.startOverAction}</from-action> <from-outcome>again</from-outcome> <to-view-id>/index.xhtml</to-view-id> </navigation-case>
conditional navigation cases
The below navigation case is only activated if the condition is fulfilled.
<navigation-case> <from-outcome>previous</from-outcome> <if>#{quizBean.currentQuestion != 0}</if> <to-view-id>/main.xhtml</to-view-id> </navigation-case>
dynamic target view id's
to-view-id
can use a value expression
<navigation-rule> <from-view-id>/main.xhtml</from-view-id> <navigation-case> <to-view-id>#{quizBean.nextViewID}</to-view-id> </navigation-case> </navigation-rule>
Updated