Preemptive navigation is a new feature in JavaServer Faces
2.0 and allows runtime introspection of control flow cases for their target
view.The JSF API for this is the ConfigurableNavigationHandler class that
exposes the following methods
getNavigationCase(FacesContext context,
java.lang.String fromAction,
java.lang.String outcome)
Map<String, Set<NavigationCase>>
thatThe NavigationCase
class wraps the information defined for a navigation, including the condition
(also a new feature in JSF 2.0) in which the navigation case is valid.
Preemptive navigation can be used in an application to
populate redirect components, like the goLink shown below with a target view,
or for redirects in a managed bean, for which developers need to know the
target view. The sample below shows an ADF Faces goLink pointing to a managed bean. The managed bean returns the
redirect URL for the link to follow when clicked on.
The managed bean accesses the NavigationHandler defined for the JSF
instance and verifies it to be an instance of ConfigurableNavigationHandler before it looks
up the target viewId for the control flow case.
Note that ADFc in Oracle JDeveloper 11g R2 also
supports conditional navigation, in which case developers can define an EL
expression on the control flow case, using the Property Inspector, that
determines when a navigation case is valid and when it is not.