Expert Spring MVC and Web Flow

(Dana P.) #1

As you can see, if the shippingproperty of the purchasebean in flow scopeevaluates to
true, the flow will transition to the enterShippingDetailsstate; otherwise, the flow will transi-
tion to the placeOrderstate.
In this scenario the decision-state evaluation criteria is an expression defined within the
flow definition. Had the decision criteria been more complex, it could have been made in Java
application code. You’ll see how to do this in Chapter 12.


■NoteYou’ll learn how to invoke methods on business objects to drive decision-state decisions in Chapter 12.


Action States


Once all information about the product purchase has been collected from the user and vali-
dated, the purchase order can be submitted. The processing of the purchase order is the first
time in this flow where the business tier needs to be invoked, within a transactional context.
The action state is designed to invoke application code, and perhaps code that is non-
indempotent (it should not be repeated). When an action state is entered, one or more actions
are invoked. What these actions do is up to you. In this case, you are interested in calling the
placeOrder()method on an existing OrderClerkbusiness façade. See Listing 11-10.


Listing 11-10.OrderClerk Interface


@Transactional
public interface OrderClerk {
void placeOrder(Purchase purchase);
}


To do this, you simply instruct the flow to call the placeOrder()method for you when the
action state is entered, as shown in Listing 11-11.


Listing 11-11./WEB-INF/flows/purchase-flow.xmlContaining placeOrder Action State











</view-state>

CHAPTER 11 ■INTRODUCTION TO SPRING WEB FLOW 327
Free download pdf