Expert Spring MVC and Web Flow

(Dana P.) #1

End states effectively define possible flow outcomes (see Listing 11-12). In the Purchase
Product flow there are two possible outcomes: canceland showCostConfirmation.


Listing 11-12./WEB-INF/flows/purchase-flow.xmlContaining End States












else="placeOrder"/>

<view-state id="enterShippingDetails" view="shippingForm">
<transition on="submit" to="placeOrder">
<action bean="sellItemAction" method="bindAndValidate"/>
</transition>
</view-state>









End states can optionally select ending or confirmation views that should be
rendered when they are entered. In this scenario, the showCostConfirmationstate selects
the costConfirmationview, which will display a summary of the purchase order cost after
order placement.
End states may also be used to trigger redirects after flow, which is a common pattern to
further restrict accidental Back button usage by redirecting the user to a new browser URL.


The Purchase Product Flow: What’s Next


At this point, the purchase order flow has been fully implemented. Listing 11-12 contains a
human-readable, self-contained definition that fully encapsulates the navigation rules for the
purchase product use case—allowing you to change navigation rules without impacting any-
thing else in the system. This module can now be fully tested out of the container and readied
for deployment within the container.


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