Exposing POJO Method Return Values
If you wish to have the return value of an invoked method exposed in either flow scope or
request scope, you must set the property resultNameto the name under which you want it
stored and the resultScopeproperty to either flowor request(the default is request). If you
do not explicitly set the resultNameproperty, the return value will not be stored in any scope.
Refer to Listing 12-24.
Listing 12-24.placeOrder Definition Exposing an orderConfirmation Return Value in Request Scope
The preceding action-state definition reads: “When the placeOrderstate is entered, invoke
the placeOrdermethod on the orderClerk bean, passing in the purchaseobject from flow
scope as input. Expose the method return value in request scope under the name
orderConfirmation. On success, transition to the showCostConfirmationstate.”
Customizing View Selection with View States and End States
Recall from Chapter 11 that view states instruct Spring Web Flow to pause the execution of a
flow and render a view allowing the user to participate in the flow.
Spring Web Flow creates logical view selections (consisting of a view name and a set of
model data), but the resolution of those view selections to a renderable Viewis the responsibil-
ity of the calling web framework. That said, Spring Web Flow allows you full control over view
selection logic via the org.springframework.webflow.ViewSelector interface.
Listing 12-25.org.springframework.webflow.ViewSelector
public interface ViewSelector {
ViewSelection makeSelection(RequestContext context);
}
This interface allows you to customize how the view name is calculated and/or what
model data is available to the view.
The ViewSelectionreturned by the ViewSelectoris then converted into a renderable arti-
fact by the calling web framework (e.g., a Struts ActionForwardor a Spring MVC ModelAndView).
This conversion is performed by the appropriate Front Controller (FlowActionfor Struts or
FlowControllerfor Spring MVC). Figure 12-3 illustrates this conversion.
CHAPTER 12 ■ADVANCED SPRING WEB FLOW 363