Java Reference
In-Depth Information
within the navigation rules, which will facilitate conditional navigation. Table 2-2 lists the different elements, along
with an explanation of what they do.
As mentioned previously, flow navigation can be specified in XML format by placing it inside an XML file
entitled flowName-flow.xml . Within this file, specify an html element that contains standard JSF taglib
declarations. However, an additional taglib must be declared to enable flow configuration access. The new taglib,
xmlns:j=" http://xmlns.jcp.org/jsf/flow " , allows access to those navigational elements listed in Table 2-2 .
The following flow configuration is an example containing flow navigation that using conditional logic:
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns=" http://www.w3.org/1999/xhtml "
xmlns:f=" http://xmlns.jcp.org/jsf/core "
xmlns:h=" http://xmlns.jcp.org/jsf/html "
xmlns:j=" http://xmlns.jcp.org/jsf/flow " >
<f:metadata>
<j:faces-flow-definition>
<j:initializer>#{flowBean.initializeIt}</j:initializer>
<j:start-node>exampleFlow</j:start-node>
<j:switch id="startNode">
<j:navigation-case>
<j:if>#{flowBean.someCondition}</j:if>
<j:from-outcome>newView</J;from-outcome>
</j:navigation-case>
</j:switch>
<j:flow-return id="exit">
<j:navigation-case>
<j:from-outcome>exitFlow</j:from-outcome>
</j:navigation-case>
</j:flow-return>
<j:finalizer>#{flowBean.finalizeIt}</j:finalizer>
</j:faces-flow-definition>
</f:metadata>
</html>
As mentioned previously, flow navigation can also be defined within Java code by utilizing the flow builder API.
To use this technique, create a new Java class that is named the same as the flow identifier, and annotate it with
@FlowDefinition , which will earmark it as a flow definition class. Within the class, a method named defineFlow
should be implemented, which will accept FacesContext and FlowBuilder objects. The FlowBuilder can then be
used to construct the rules for the flow.
import javax.faces.context.FacesContext;
import javax.faces.flow.Flow;
import javax.faces.flow.FlowDefinition;
import javax.faces.flow.builder.FlowBuilder;
import javax.inject.Named;
 
Search WWH ::




Custom Search