Java Reference
In-Depth Information
Flow EL
Flows contain a new EL variable named facesFlowScope . This variable is associated with the current flow, and it is
a map that can be used for storing arbitrary values for use within a flow. The key-value pairs can be stored and read
via a JSF view or through Java code within a managed bean. For example, to display the content for a particular map
key, you could use the following:
The content for the key is: #{facesFlowScope.myKey}
Java API for Flow Context
It is possible to gain access to an application's Flow context via the Java API by calling the javax.faces.application.
Application getFlowHandler() method. Calling the method will return a thread-safe singleton instance of the
FlowHandler for the application. A FlowHandler can then be used to gain access to the current flow, start a new flow,
and so on. The following Java code demonstrates some of the possibilities:
FacesContext context = FacesContext.getCurrentInstance();
Application app = context.getApplication();
// Obtain the FlowHandler
FlowHandler handler = app.getFlowHandler();
// Obtain the current Flow
Flow flow = handler.getCurrentFlow();
// Obtain the current facesFlowScope Map content
Map flowScope = handler.getCurrentFlowScope();
// Add a new flow
Flow newFlow = new ExampleFlow();
handler.addFlow(context, newFlow, flow);
Flows cannot be altered once they are defined because they are immutable. the FlowHandler can gain access
to a current flow to see information regarding the flow, but it cannot be used to dynamically alter the flow.
To learn the complete Java API, the best resource is to study the Javadoc for flows, which can be found at .
Packaging a Flow
If a flow can be useful for more than one application, it can be made portable by packaging it up inside a JAR file.
Once packaged, the flow can be brought into applications by simply including the JAR file in the application CLASSPATH .
To package a flow, create a specific directory structure that includes the flow views, navigational XML, and any managed
beans that may be used by the flow.
To create the directory structure, place a META-INF folder at the root, and then create a subdirectory for each of
the flows that are packaged in the JAR. The subdirectory should be entitled flows , and it should contain a directory for
each flow that will be packaged. Each of the flow directories should have the same name as the flow identifier. The flows
must be explicitly defined in a faces-config.xml file that resides within the META-INF folder. Each of the nodes within a
flow should be placed within the flow subdirectory. All Java code that belongs to a flow, such as the @FlowScoped and
Search WWH ::

Custom Search