From 893df095c6d01ae3cc61ed763f57b63aa034752a Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 31 Mar 2014 15:03:11 -0400 Subject: [PATCH] Update reference with Java config examples --- src/reference/spring-faces.xml | 10 +- src/reference/spring-js.xml | 8 +- src/reference/system-setup.xml | 247 +++++++++++++++++++++++++++++--- src/reference/upgrade-guide.xml | 4 +- src/reference/views.xml | 8 +- src/reference/whatsnew.xml | 62 ++++++-- 6 files changed, 296 insertions(+), 43 deletions(-) diff --git a/src/reference/spring-faces.xml b/src/reference/spring-faces.xml index 77b944f8..4b5877f7 100644 --- a/src/reference/spring-faces.xml +++ b/src/reference/spring-faces.xml @@ -207,11 +207,11 @@ xsi:schemaLocation=" xmlns:faces="http://www.springframework.org/schema/faces" si:schemaLocation=" http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-3.0.xsd + http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/webflow-config - http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd + http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.4.xsd http://www.springframework.org/schema/faces - http://www.springframework.org/schema/faces/spring-faces-2.2.xsd"> + http://www.springframework.org/schema/faces/spring-faces-2.4.xsd"> <!-- Executes flows: the central entry point into the Spring Web Flow system --> <webflow:flow-executor id="flowExecutor"> @@ -251,9 +251,9 @@ xsi:schemaLocation=" xmlns:faces="http://www.springframework.org/schema/faces" xsi:schemaLocation=" http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-3.0.xsd + http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/faces - http://www.springframework.org/schema/faces/spring-faces-2.2.xsd"> + http://www.springframework.org/schema/faces/spring-faces-2.4.xsd"> <faces:resources /> diff --git a/src/reference/spring-js.xml b/src/reference/spring-js.xml index 4a441788..581eae2d 100644 --- a/src/reference/spring-js.xml +++ b/src/reference/spring-js.xml @@ -53,8 +53,8 @@ + xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"> @@ -102,8 +102,8 @@ + xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"> ... diff --git a/src/reference/system-setup.xml b/src/reference/system-setup.xml index 94b19677..6f6d0410 100644 --- a/src/reference/system-setup.xml +++ b/src/reference/system-setup.xml @@ -14,11 +14,14 @@ This chapter shows you how to setup the Web Flow system for use in any web environment. - - webflow-config.xsd + + Java Config and XML Namespace - 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: + Web Flow provides dedicated configuration support for both Java and + XML-based configuration. + + + To get started with XML based configuration declare the webflow config XML namespace: + http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.4.xsd"> ]]> + + To get started with Java configuration extend + AbstractFlowConfiguration in an + @Configuration class: + + + Basic system configuration @@ -43,21 +59,41 @@ FlowRegistry - Register your flows in a FlowRegistry: + Register your flows in a FlowRegistry in XML: ]]> + + Register your flows in a FlowRegistry in Java: + + + FlowExecutor - Deploy a FlowExecutor, the central service for executing flows: + Deploy a FlowExecutor, the central service for executing flows in XML: ]]> + + + Deploy a FlowExecutor, the central service for executing flows in Java: + + 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. @@ -73,25 +109,48 @@ 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. + By default, flows will be assigned registry identifiers equal to their filenames minus + the file extension, unless a registry bath path is defined. + + + In XML: ]]> + + In Java: + + + Assigning custom flow identifiers - Specify an id to assign a custom registry identifier to a flow: + Specify an id to assign a custom registry identifier to a flow in XML: ]]> + + Specify an id to assign a custom registry identifier to a flow in Java: + + + Assigning flow meta-attributes - Use the flow-definition-attributes element to assign custom meta-attributes to a registered flow: + Use the flow-definition-attributes element to assign custom meta-attributes to a registered flow. + + + In XML: @@ -100,15 +159,36 @@ ]]> + + In Java: + + attrs = ... ; + +return getFlowDefinitionRegistryBuilder() + .addFlowLocation("/WEB-INF/flows/booking/booking.xml", null, attrs) + .build();]]> + Registering flows using a location pattern Use the flow-location-patterns element to register flows that match a specific resource location pattern: + + In XML: + ]]> + + In Java: + + + Flow location base path @@ -117,10 +197,22 @@ 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'. + + In XML: + ]]> + + + In Java: + + With a base path defined, the algorithm that assigns flow identifiers changes slightly. @@ -142,12 +234,21 @@ 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: + For example in XML: ]]> + + + In Java: + + In the above example, suppose you had flows located in /user/login, /user/registration, /hotels/booking, and /flights/booking directories within WEB-INF, @@ -160,6 +261,9 @@ 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. + + In XML: + @@ -171,6 +275,36 @@ ]]> + + In Java: + + + Configuring custom FlowBuilder services @@ -179,16 +313,34 @@ 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. + In XML: ]]> + + In Java: + 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: + These services are configured by referencing custom beans you define. + + + For example in XML: ]]> + + In Java: + conversion-service @@ -245,7 +423,8 @@ Attaching flow execution listeners - Use the flow-execution-listeners element to register listeners that observe the lifecycle of flow executions: + Use the flow-execution-listeners element to register listeners that observe the lifecycle + of flow executions. For example in XML: @@ -254,21 +433,57 @@ ]]> - You may also configure a listener to observe only certain flows: + In Java: + + + + + You may also configure a listener to observe only certain flows. For example in XML: ]]> + + In Java: + + + Tuning FlowExecution persistence - Use the flow-execution-repository element to tune flow execution persistence settings: + Use the flow-execution-repository element to tune flow execution persistence settings. + For example in XML: ]]> + + + In Java: + + max-executions diff --git a/src/reference/upgrade-guide.xml b/src/reference/upgrade-guide.xml index d0da31f1..c2627518 100644 --- a/src/reference/upgrade-guide.xml +++ b/src/reference/upgrade-guide.xml @@ -125,9 +125,9 @@ java org.springframework.webflow.upgrade.WebFlowUpgrader flow-to-upgrade.xml 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-3.0.xsd + http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/webflow-config - http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd"> + http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.4.xsd"> ]]> flow-executor diff --git a/src/reference/views.xml b/src/reference/views.xml index 1f53e770..6f3a3cd4 100644 --- a/src/reference/views.xml +++ b/src/reference/views.xml @@ -241,9 +241,9 @@ public class ApplicationConversionService extends DefaultConversionService { xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation=" http://www.springframework.org/schema/mvc - http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd + http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> + http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"> ]]> @@ -288,9 +288,9 @@ public class ApplicationConversionServiceFactoryBean extends FormattingConversio xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation=" http://www.springframework.org/schema/mvc - http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd + http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> + http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"> diff --git a/src/reference/whatsnew.xml b/src/reference/whatsnew.xml index 1e689ee3..a3de1615 100644 --- a/src/reference/whatsnew.xml +++ b/src/reference/whatsnew.xml @@ -10,11 +10,59 @@ What's New Spring Web Flow 2.4 + This release requires JDK 1.6. + + Java-based Configuration + + Web Flow now supports a Java-based alternative for its system configuration. + See the updated . + + + Also see the + booking-mvc and + booking-faces + samples that have been updated to use all Java config. + + + + Spring MVC Flash Scope Integration + + When a flow ends it can now redirect to a Spring MVC controller after saving + attributes in Spring MVC's flash scope for the controller to access. + + + See . + + + + Partial JSR-303 Bean Validation + + A flow definition can apply partial validation on the model through the validation-hints + attribute supported on view state and transition elements. + + + See . + + + + Hibernate4 Support + + The HibernateFlowExecutionListener now supports Hibernate 4 in addition to Hibernate 3. + + + + Tiles 3 Support + + The AjaxTilesView now supports Tiles 3 in addition to Tiles 2.2. + + Minimum JSF 2.0 Requirement Java ServerFaces version 1.2 and earlier are no longer supported by Spring Web Flow, if you have not done so already you will need to upgrade to JSF 2.0 or above. In addition the Spring Faces components that were previously provided with JSF 1.2 for progressive AJAX enhancements have been removed in this release. + + See . @@ -24,20 +72,10 @@ The internal Portlet integration introduced in Spring Web Flow 2.2 has been upgraded for JSF 2.0 compatibility. Some of the more advanced JSF 2.0 features, such as partial state saving, are not supported in a Portlet environment, however, existing application can now upgrade to the minimum required JSF version. Upgraded projects will need to ensure that the <faces:resources> elements is - included as part of their Spring configuration. See . + included as part of their Spring configuration. - - - Saving Flow Output to Spring MVC Flash Scope - Flow output can now be saved to Spring MVC Flash Scope for any end-state that issues an internal redirect. To enable this feature set FlowHandlerAdapter.saveOutputToFlashScopeOnRedirect. See . - - - - Partial JSR-303 Bean Validation - - Partial validation with JSR-303 Bean Validation groups is now supported through the validation-hints - view-state attribute. See . + See .