Problem

A global navigation rule is a rule that applies to all pages. For example, apply a “logout” navigation rule that every pages are allow to access. Is there a way to configure it in JSF?

Solution

In JSF, wildcard is supported in navigation rule, you can use a “*” to specify a navigation rule that applies to all pages.

<navigation-rule>
   <from-view-id>*</from-view-id>
   <navigation-case>
	<from-outcome>logout</from-outcome>
	<to-view-id>logout.xhtml</to-view-id>
   </navigation-case>
</navigation-rule>

In this example, all the pages in your web application is able to access the “logout” navigation.

See another example,

<navigation-rule>
   <from-view-id>/customer/*</from-view-id>
   <navigation-case>
	<from-outcome>validation</from-outcome>
	<to-view-id>customer-validation.xhtml</to-view-id>
   </navigation-case>
</navigation-rule>

This rule applies to all pages that start with the prefix /customer/.

Note
The “*” wildcard functionality is limited in JSF, because only one “*” is allowed, and it must be at the end of the “form-view-id” string. For example,

It works.

<from-view-id>/customer/*</from-view-id>

It will never match…

<from-view-id>/cus*mer/</from-view-id>
<from-view-id>/c*sto*er/*</from-view-id>
<from-view-id>*/customer</from-view-id>
Note : You can find more similar articles at - JSF 2 Tutorials