spring-projects / spring-webflow

Spring Web Flow
https://spring.io/projects/spring-webflow
Apache License 2.0
331 stars 234 forks source link

Spring 3 Type Conversion and Formatting Integration [SWF-1234] #440

Closed spring-operator closed 14 years ago

spring-operator commented 14 years ago

Rossen Stoyanchev opened SWF-1234 and commented

Currently Spring Web Flow applications rely on a type conversion system that is different from the mechanism used in Spring MVC, which relied on the java.beans.PropertyEditor abstraction. Spring 3 offers a modern type conversion mechanism influenced by Web Flow's type conversion mechanism. Of interest to web applications is the Formatter SPI and the annotation-driven formatting:

http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/validation.html#format

The purpose of this ticket is to integrate the new Spring conversion system into Web Flow such that Web Flow applications can take advantage of it and use a single type conversion mechanism. The specific goals are:

  1. Replace the default Web Flow converters with Spring 3 converters
  2. Make it possible to continue to use existing custom Web Flow converters
  3. Make it possible for applications to start relying on Spring 3 formatters and formatting annotations

After this change all type conversion in Web Flow will rely on Spring's type conversion system. Existing custom converters can be registered as before via registered via GenericConversionService.addConverter(Converter converter). Such converters will be adapted and registered for use withing Spring's type conversion system.

Web Flow also provides support for named converters that can be added via GenericConversionService.addConverter(String id, Converter converter). Such converters can then be used in conjunction with data binding. Named converters will continue to be supported for backwards compatibility but will be deprecated and will not result in the use of Spring's type conversion mechanism.

Why applications should consider rewriting existing custom converters? Formatters are smart with regards to generics, formatting annotations (including custom annotations) provide fine-grained control over formatting, a single mechanism can be used across Spring MVC and Spring Web Flow.


Affects: 2.0.9

Issue Links:

spring-operator commented 14 years ago

Rossen Stoyanchev commented

The Spring 3 type conversion integration is now fully functional.

Applications should be able to continue to work without making any changes. However all type conversion will now be routed through Spring's type conversion with the exception of named, custom converters.

The samples have been updated. Noteworthy changes are the addition of a dependency on org.joda.time and the removal of the "shortDate" named converter in swf-booking-mvc and booking-portlet-mvc in favor of @DateTimeFormat annotations in Booking.java.

Applications can also start registering custom Spring 3 formatters and formatting annotations through Spring's FormattingConversionServiceFactoryBean. In Spring MVC applications this is commonly configured via . Web Flow applications on the other hand use the to point to a custom DefaultConversionService. To combine the two simply create an instance of a Web Flow DefaultConversionService using the constructor that accepts an instance of a Spring ConversionService.