System Setup Introduction This chapter shows you how to setup the Web Flow system for use in any web environment. webflow-config.xsd Web Flow provides a Spring schema that allows you to configure the system. To use this schema, include it in one of your infrastructure-layer beans files: <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:webflow="http://www.springframework.org/schema/webflow-config" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/webflow-config http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd"> <!-- Setup Web Flow here --> </beans> Basic system configuration The next section shows the minimal configuration required to set up the Web Flow system in your application. FlowRegistry Register your flows in a FlowRegistry: <webflow:flow-registry id="flowRegistry"> <webflow:flow-location path="/WEB-INF/flows/booking/booking.xml" /> </webflow:flow-registry> FlowExecutor Deploy a FlowExecutor, the central service for executing flows: <webflow:flow-executor id="flowExecutor" flow-registry="flowRegistry" /> See the Spring MVC and Spring Faces sections of this guide on how to integrate the Web Flow system with the MVC and JSF environment, respectively. flow-registry options Configuring custom FlowBuilder services Use the flow-builder-services attribute to customize the services used to build the flows in a registry. If no flow-builder-services tag is specified, the default service implementations are used. When the tag is defined, you only need to reference the services you want to customize. <webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices"> <webflow:flow-location path="/WEB-INF/flows/booking/booking.xml" /> </webflow:flow-registry> <webflow:flow-builder-services id="flowBuilderServices" /> The configurable services are the conversion-service, formatter-registry, expression-parser, and view-factory-creator. These services are configured by referencing custom beans you define. For example: <webflow:flow-builder-services id="flowBuilderServices" conversion-service="conversionService" formatter-registry="formatterRegistry" expression-parser="expressionParser" view-factory-creator="viewFactoryCreator"/> <bean id="conversionService" class="..." /> <bean id="formatterRegistry" class="..." /> <bean id="expressionParser" class="..." /> <bean id="viewFactoryCreator" class="..." /> conversion-service Use the conversion-service attribute to customize the ConversionService used by the Web Flow system. Converters are used to convert from one type to another when required during flow execution. The default ConversionService registers converters for your basic object types such as numbers, classes, and enums. formatter-registry Use the formatter-registry attribute to customize the FormatterRegistry used by the Web Flow system. Formatters are used by Views to format model property values for display. The default FormatterRegistry registers converters for your basic model object types such as numbers and dates. expression-parser Use the expression-parser attribute to customize the ExpressionParser used by the Web Flow system. The default ExpressionParser uses the Unified EL if available on the classpath, otherwise OGNL is used. view-factory-creator Use the view-factory-creator attribute to customize the ViewFactoryCreator used by the Web Flow system. The default ViewFactoryCreator produces Spring MVC ViewFactories capable of rendering JSP, Velocity, and Freemarker views. Configuring FlowRegistry hierarchies Use the parent attribute to link two flow registries together in a hierarchy. When the child registry is queried, if it cannot find the requested flow it will delegate to its parent. <!-- my-system-config.xml --> <webflow:flow-registry id="flowRegistry" parent="sharedFlowRegistry"> <webflow:flow-location path="/WEB-INF/flows/booking/booking.xml" /> </webflow:flow-registry> <!-- shared-config.xml --> <webflow:flow-registry id="sharedFlowRegistry"> <-- Global flows shared by several applications --< </webflow:flow-registry> Specifying flow locations Use the location element to specify paths to flow definitions to register. By default, flows will be assigned registry identifiers equal to their filenames minus the file extension. <webflow:flow-location path="/WEB-INF/flows/booking/booking.xml" /> Assigning custom flow identifiers Specify an id to assign a custom registry identifier to a flow: <webflow:flow-location path="/WEB-INF/flows/booking/booking.xml" id="bookHotel" /> Assigning flow meta-attributes Use the flow-definition-attributes element to assign custom meta-attributes to a registered flow: <webflow:flow-location path="/WEB-INF/flows/booking/booking.xml"> <flow-definition-attributes> <attribute name="caption" value="Books a hotel" /> <attribute name="persistence-context" value="true" type="boolean" /> </flow-definition-attributes> </webflow:flow-location> flow-executor options Attaching flow execution listeners Use the flow-execution-listeners element to register listeners that observe the lifecycle of flow executions: <flow-execution-listeners> <listener ref="securityListener"/> <listener ref="persistenceListener"/> </flow-execution-listeners> You may also configure a listener to observe only certain flows: <listener ref="securityListener" criteria="securedFlow1,securedFlow2"/> Tuning FlowExecution persistence Use the flow-execution-repository element to tune flow execution persistence settings: <flow-execution-repository max-conversations="5" max-snapshots="30" /> max-conversations Tune the max-conversations attribute to place a cap on the number of conversations that can be created per user session. max-snapshots Tune the max-snapshots attribute to place a cap on the number of flow execution snapshots that can be taken per conversation. conversation-manager Set a custom ConversationManager to completely customize where conversational flow state is persisted.