Class FlowHandler

java.lang.Object
jakarta.faces.flow.FlowHandler
Direct Known Subclasses:
FlowHandlerImpl

public abstract class FlowHandler extends Object

FlowHandler is the main entry point that enables the runtime to interact with the faces flows feature. NavigationHandler uses this class when it needs to make navigational decisions related to flows. The faces flow feature entirely depends on the ClientWindow feature and also on CDI.

Defining Flows

The implementation must support defining faces flows using the <flow-definition> element as specified in the Application Configuration Resources XML Schema Definition, or by using the FlowBuilder API. Additional means of defining flows may be provided by decorating the FlowHandlerFactory.

Managing Flows

The singleton instance of this class must be thread safe, and therefore must not store any per-user state. Flows are, however, traversed in a per-user manner, and must be associated with the current ClientWindow. Furthermore, Flows may be nested. These requirements strongly suggest managing the flows with a stack-like runtime data structure, stored in a per-user fashion and associated with the ClientWindow. Because Flow instances are immutable, yet the flow stack is per-user, implementations must make allowance for flow scoped data (managed beans declared to be FlowScoped and data stored in the Map returned by getCurrentFlowScope()) to be fully re-entrant. For example, consider an application with two flows, A and B, each with a single FlowScoped bean MyBeanA and MyBeanB, respectively. Entry into flow A causes MyBeanA to become active. Calling from A into B causes MyBeanB to become active. Calling back into A causes a new instance of MyBeanA to become active, rather than reactivating the earlier instance of MyBeanA.

The Flow Graph

Prior versions of the specification defined a flow graph but the only kind of node in the graph was a VDL view. The Faces Flow feature currently defines the following node types.

  • View

    This is the regular Jakarta Faces VDL View that has been in the specification since the beginning.

  • Switch

    This is a list of Jakarta Expression Language expressions. When control is passed to a switch node, each expression in the list is evaluated and the first one that returns true is used to define the id of the next node to which control must be passed. If none of the expressions evaluates to true, control passes to the specified default id.

  • Return

    This node type specifies an outcome that is returned to the calling flow.

  • Method Call

    This node type allows invocation of arbitrary application logic at any point in the executiong of the flow. An outcome can be specified that will cause a navigation case to be navigated to after the method has been invoked.

  • Faces Flow Call

    This node type allows one flow to call another flow. The calling flow remains active and is not exited until control returns from the called flow.

Edges in the graph are defined by the existing Jakarta Faces navigation rule system.

Flows and Model Objects

Managed beans annotated with the CDI annotation FlowScoped are created lazily, when referenced, after a user agent's entry into the named scope, and must be made available for garbage collection when the user agent leaves the flow.

The flowScope Jakarta Expression Language implicit object is also available to store values in the "current" slope. Values stored in this scope must be made available for garbage collection when the user agent leaves the flow.

Since:
2.2