Table 11-4.Action Execution Points Within the Flow Life Cycle
Point Description
On flow start Execute one or more “start actions” when a flow starts.
On flow end Execute one or more “end actions” when a flow ends.
On state enter Execute one or more “entry actions” when a state is entered.
On state exit Execute one or more “exit actions” when a state is exited.
Before transition Execute one or more “transition actions” before executing a transition.
In this case, you are interested in executing view prerender logic when the
enterPurchaseInformationstate is entered. Then, on execution of the submittransition you
are interested in executing data binding and validation postback logic. See Listing 11-4.
Listing 11-4./WEB-INF/flows/purchase-flow.xmlContaining Entry Actions
<flow start-state="enterPurchaseInformation">
<view-state id="enterPurchaseInformation" view="purchaseForm">
<entry-actions>
<action bean="formAction" method="setupForm"/>
</entry-actions>
<transition on="submit" to="requiresShipping">
<action bean="formAction" method="bindAndValidate"/>
</transition>
<transition on="cancel" to="cancel"/>
</view-state>
</flow>
The preceding instruction now reads, “When an execution of this flow starts, enter the
enterPurchaseInformationstate. When the state is entered, first execute the setupForm()
method on the formAction. Then select the purchaseFormview for display to the user, and
pause the flow execution until a user event is signaled.”
The submit transition instruction now reads, “On the occurrence of the submitevent,
transition to the requiresShippingstate if the bindAndValidate()method on the formAction
executes successfully.”
This gives you behavior typical of a form view state, executing prerender logic as part of a
state entry action, and postback logic as part of a specific transition action. If the transition
action returns a result other than success, the transition will not be allowed, and the state will
be reentered. This allows us to respond to data binding and validation errors correctly by
redisplaying the view so the user can review the errors and revise his edits.
Action Bean Definitions
At this point you have referenced an Actionbean from the flow definition with the formAction
identifier (<action bean="formAction" method="setupForm"/>).
322 CHAPTER 11 ■INTRODUCTION TO SPRING WEB FLOW