<property name="formObjectClass" value="purchase.domain.Shipping"/>
<property name="formObjectScope" value="FLOW"/>
<property name="validator">
<bean class="purchase.domain.ShippingValidator"/>
</property>
</bean>
</beans>
Finally the flowRegistrybean in /WEB-INF/flows.xmlis updated to include the new sub-
flow, as shown in Listing 12-6.
Listing 12-6.Modified flowRegistry Definition
<bean name="flowRegistry"➥
class="org.springframework.webflow.registry.XmlFlowRegistryFactoryBean">
<property name="flowLocations">
<list>
<value>/WEB-INF/flows/purchase-flow.xml</value>
<value>/WEB-INF/flows/shipping-flow.xml</value>
</list>
</property>
</bean>
The subflow is now ready to be used. The next step is to replace the extracted fragment in
/WEB-INF/flows/purchase-flow.xmlwith a new subflow-state definition that instructs the flow
to spawn the shipping flow as a subflow. The refactored purchase flow is shown in Listing 12-7.
Listing 12-7.Modified/WEB-INF/flows/purchase-flow.xml
<flow start-state="enterPurchaseInformation">
<view-state id="enterPurchaseInformation" view="purchaseForm">
<entry-actions>
<action bean="formAction" method="setupForm"/>
</entry-actions>
<transition on="submit" to="enterShippingInformation">
<action bean="formAction" method="bindAndValidate"/>
</transition>
<transition on="cancel" to="cancel"/>
</view-state>
<subflow-state id="enterShippingInformation" flow="shipping-flow">
<attribute-mapper>
<input-mapping name="purchase.requiresShipping" as="requiresShipping"/>
<output-mapping name="shipping" as="purchase.shipping"/>
</attribute-mapper>
<transition on="finish" to=”placeOrder"/>
</subflow-state>
340 CHAPTER 12 ■ADVANCED SPRING WEB FLOW