Java Reference
In-Depth Information
However, if you have only a small number of flows in an application, it may be simpler to include the flow navigation
rules in the faces-config.xml file. If flow definition XML files are utilized, they must be placed within either a
directory at the web root of the application that is named after the flow (/<flow-name>/<flow-name>-flow.xml ),
or a directory named after the flow that resides at the root of the WEB-INF directory (/WEB-INF/<flow-name>/
<flow-name>-flow.xml ). If you prefer to not use XML, then building out flow navigational rules in Java code is
possible using the Flow API, which utilizes a builder pattern.
Each flow should include two or more views, which we will refer to as nodes . As such, each flow has a beginning
node, an ending node, and optional intermediate nodes, which are also known as view nodes . Importantly, a flow
also contains its own CDI managed bean, which is used to define methods and variables for use by each view node
in the flow. The managed bean must be annotated with @FlowScoped to signify that it exists within the flow scope, and
the annotation should specify an id attribute that contains the name of the flow to which the managed bean belongs.
The following Java class, named FlowBean , demonstrates how to define a managed bean for use with a flow named
exampleFlow :
import javax.faces.flow.FlowScoped;
import javax.inject.Named;
public class FlowBean implements {
private String beanValue = "From the flowBean";
* Creates a new instance of FlowBean
public FlowBean() {
public void initializeIt(){
System.out.println("Initialize the flow...");
public void finalizeIt(){
System.out.println("Finalize the flow...");
public String navMethod(){
return "nextViewNode";
* @return the beanValue
public String getBeanValue() {
return beanValue;
Search WWH ::

Custom Search