Expert Spring MVC and Web Flow

(Dana P.) #1

■NoteA flow that is called from another flow is referred to as a subflow.See Chapter 12 for more details.


Before walking through the implementation of the example flow, we’ll use the following
sections to define some important terminology and concepts.

Flows
Within Spring Web Flow, a flow defines a conversation, or dialogue, between users and the
server. It serves as a blueprint for a use case or business process. The Purchase Product use
case is one example of a flow.

States
The steps of a flow are called states. A state encapsulates behavior that executes when the state
is entered. The exact behavior is a function of the state’s type. Spring Web Flow provides five
core types of states, shown in Table 11-3.

Table 11-3.Types of States
Name Description
Action state Executes your application code, typically delegating to a business service in the
middle tier.
View state Renders a view allowing the user to participate in the flow by entering data or
viewing a message.
Subflow state Spawns another flow as a subflow. The spawning flow is suspended until the
subflow reaches an end state, at which point the subflow will end and the
spawning flow will resume.
Decision state Evaluates a condition to drive a transition to a new state.
End state Terminates a flow.

Every flow definition must contain exactly one start state and at least one end state.

Transitions
All states except end states are transtionable and maintain a set of one or more transitions that
define “allowed paths” to other states. A transition is triggered on the occurrence of an event.

Events
An event is nothing more than “something that happens” within a state. An event is treated as
a state outcome that captures the logical result of a state’s execution.
From Figure 11-4, you can see the event names such as “submit” and “yes” driving state
transitions (the arrows between states). The “submit” event communicates that a submit button
was pressed as the outcome of a view state, and the “yes” event communicates that a trueresult
was returned when evaluating a conditional expression as the outcome of a decision state.

318 CHAPTER 11 ■INTRODUCTION TO SPRING WEB FLOW

Free download pdf