9.4. flow-registry options

This section explores flow-registry configuration options.

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, unless a registry bath path is defined.

<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" />
    </flow-definition-attributes>
</webflow:flow-location>
			

Registering flows using a location pattern

Use the flow-location-patterns element to register flows that match a specific resource location pattern:

<webflow:flow-location-pattern value="/WEB-INF/flows/**/*-flow.xml" />
			

Flow location base path

Use the base-path attribute to define a base location for all flows in the application. All flow locations are then relative to the base path. The base path can be a resource path such as '/WEB-INF' or a location on the classpath like 'classpath:org/springframework/webflow/samples'.

<webflow:flow-registry id="flowRegistry" base-path="/WEB-INF">
    <webflow:flow-location path="/hotels/booking/booking.xml" />
</webflow:flow-registry>
			

With a base path defined, the algorithm that assigns flow identifiers changes slightly. Flows will now be assigned registry identifiers equal to the the path segment between their base path and file name. For example, if a flow definition is located at '/WEB-INF/hotels/booking/booking-flow.xml' and the base path is '/WEB-INF' the remaining path to this flow is 'hotels/booking' which becomes the flow id.

[Tip]Directory per flow definition

Recall it is a best practice to package each flow definition in a unique directory. This improves modularity, allowing dependent resources to be packaged with the flow definition. It also prevents two flows from having the same identifiers when using the convention.

If no base path is not specified or if the flow definition is directly on the base path, flow id assignment from the filename (minus the extension) is used. For example, if a flow definition file is 'booking.xml', the flow identifier is simply 'booking'.

Location patterns are particularly powerful when combined with a registry base path. Instead of the flow identifiers becoming '*-flow', they will be based on the directory path. For example:

<webflow:flow-registry id="flowRegistry" base-path="/WEB-INF">
    <webflow:flow-location-pattern value="/**/*-flow.xml" />
</webflow:flow-registry>
			

In the above example, suppose you had flows located in /user/login, /user/registration, /hotels/booking, and /flights/booking directories within WEB-INF, you'd end up with flow ids of user/login, user/registration, hotels/booking, and flights/booking, respectively.

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>
			

Configuring custom FlowBuilder services

Use the flow-builder-services attribute to customize the services and settings used to build flows in a flow-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, 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"
    expression-parser="expressionParser"
    view-factory-creator="viewFactoryCreator" />

<bean id="conversionService" 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.

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.

The configurable settings are development. These settings are global configuration attributes that can be applied during the flow construction process.

development

Set this to true to switch on flow development mode. Development mode switches on hot-reloading of flow definition changes, including changes to dependent flow resources such as message bundles.