A flow definition is composed of a set of states. Each state will have a unique ID in the flow definition. There are five types of state available in Spring Web Flow:
start-state
: Each flow must have a single start state, which helps in creating the initial state of the flow. Note that if the start-state
is not specified, the very first defined state within the flow definition file becomes the start state.action-state
: A flow can have many action states; an action-state
executes a particular action. An action normally involves interacting with backend services, such as executing some methods in Spring managed beans; Spring Web Flow uses the Spring Expression Language to interact with the backend service beans.view-state
: A view-state
defines a logical View and Model to interact with the end user. A web flow can have multiple view-states
. If the View attribute is not specified, then the ID of the view-state
acts as the logical View name.decision-state
: This is used to branch the flow; based on a test condition it routes the transition to the next possible state.subflow-state
: It is an independent flow that can be reused from inside another flow. When an application enters a subflow, the main flow is paused until the subflow completes.end-state
: This state denotes the end of a flow execution. A web flow can have multiple end states; through the view
attribute of an end-state
, we can specify a View that will be rendered when its end state is reached.We have just learned that a flow definition is composed of a set of states, but in order to move from one state to another, we need to define transitions in states. Each state in a web flow (except for the start and end states) defines a number of transitions to move from one state to another. A transition can be triggered by an event signaled by the state.