Spring MVC Deployment
To deploy the flow for execution within a Spring MVC environment, you need to define a
FlowControllerwhich is a special type of org.springframework.web.servlet.mvc.Controller.
One FlowControllerwill typically manage the execution of all flows within an application.
The FlowController
A FlowControllerserves as an Adapter (http://en.wikipedia.org/wiki/Adapter_pattern)
between Spring MVC and Spring Web Flow (it has knowledge of both systems). A
FlowControllerexposes a set of managed flow executions for execution at a specific
request URL.
Listing 11-13.Spring MVC DispatcherServlet Configuration
<bean name="/purchase.htm" class="org.springframework.webflow.manager.mvc.
FlowController">
<constructor-arg ref="flowRegistry"/>
</bean>
Spring MVC will now route requests for the /purchase.htmURL to the org.springframework.
webflow.mvc.FlowController. As you can see, the Controllerneeds a reference to a
flowRegistry, which contains the flow definitions that are eligible for execution.
FlowRegistry
A FlowRegistry(see Listing 11-14) is a dictionary of flow definitions eligible for execution. Flow
definitions placed in a registry are indexed by their identifiers. By default, the filename of the
flow definition, minus the file extension, is treated as the flow id.
Listing 11-14./WEB-INF/flow.xmlIncluding the purchaseFlow
<bean name="flowRegistry"
class="org.springframework.webflow.registry.XmlFlowRegistryFactoryBean">
<property name="flowLocations">
<list>
<value>/WEB-INF/flow/purchase-flow.xml</value>
</list>
</property>
</bean>
As you define new flow definitions, you simply add them as new flow locations. Wildcard
matches are also supported, building on Spring’s ResourceArrayPropertyEditor. See Listing 11-15.
330 CHAPTER 11 ■INTRODUCTION TO SPRING WEB FLOW