You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add Formatter support to DataBinder [SPR-6015] #10684
Support for the Formatter/FormatterRegistry SPI/API should be added to DataBinder, as an alternative to working with PropertyEditors. Existing PropertyEditor support should remain unaffected.
A DataBinder may pick up a FormatterRegistry reference via setFormatterRegistry, or configure its own local registry via dataBinder.getFormatterRegistry().add(...)
ConfigurableWebBindingInitializer - as supported by our AnnotationMethodHandlerAdapters through their "webBindingInitializer" property - accepts a "formatterRegistry" property as well, applying to all DataBinders created for @MVC handler invocations.
Furthermore, we have support for a shared "conversionService" bean in an ApplicationContext now: picked up by the ApplicationContext's internal BeanFactory as well as by GenericFormatterRegistry bean definitions.
I am quite puzzled about this ticket as it is marked as fixed but apprently it seems it isn't. Although there were commits on the Formatter classes, the actual DataBinder extension is still missing, so that seemingly there's no way currently to register field specfic formatting/conversion in an @InitBinder method. This is quite a blocker for a lot of people moving from PropertyEditor s to the ConversionService infrastructure. Also the getFormatterRegistry method Sam mentions in #10839 does not seem to exist (3.0.3 currently). So is there a way to achieve something like described above?
But dataBinder has no method getFormatterRegistry (at least in Spring 3.1.1)!? How can "field-specific" formatters be registered in a method annotated with @Initbinder nowadays?
I can't recall what happened to this back then: We might have considered it good enough to be able to specify a custom FormattingConversionService through DataBinder.setConversionService.
But point taken, a more convenient way to register specific custom formatters on a local binder instance, in addition to delegating to a shared ConversionService setup, would be nice. I've reactivated #12429 and #10737 for that purpose, targeting them for 4.2.
Activity
spring-projects-issues commentedon Aug 24, 2009
Juergen Hoeller commented
A DataBinder may pick up a FormatterRegistry reference via setFormatterRegistry, or configure its own local registry via dataBinder.getFormatterRegistry().add(...)
ConfigurableWebBindingInitializer - as supported by our AnnotationMethodHandlerAdapters through their "webBindingInitializer" property - accepts a "formatterRegistry" property as well, applying to all DataBinders created for
@MVChandler invocations.Furthermore, we have support for a shared "conversionService" bean in an ApplicationContext now: picked up by the ApplicationContext's internal BeanFactory as well as by GenericFormatterRegistry bean definitions.
Juergen
spring-projects-issues commentedon Jul 20, 2010
Oliver Drotbohm commented
Hi guys,
I am quite puzzled about this ticket as it is marked as fixed but apprently it seems it isn't. Although there were commits on the Formatter classes, the actual
DataBinderextension is still missing, so that seemingly there's no way currently to register field specfic formatting/conversion in an@InitBindermethod. This is quite a blocker for a lot of people moving fromPropertyEditors to theConversionServiceinfrastructure. Also thegetFormatterRegistrymethod Sam mentions in #10839 does not seem to exist (3.0.3 currently). So is there a way to achieve something like described above?Regards,
Ollie
spring-projects-issues commentedon Oct 18, 2012
Burkhard Graves commented
Albeit this task is more than two years old: Are there any news concerning the registration of "field-specific" formatters?
--dhukas
spring-projects-issues commentedon Oct 18, 2012
Oliver Drotbohm commented
As the ticket says, released in Spring 3.0 RC1.
spring-projects-issues commentedon Oct 18, 2012
Burkhard Graves commented
But dataBinder has no method getFormatterRegistry (at least in Spring 3.1.1)!? How can "field-specific" formatters be registered in a method annotated with
@Initbindernowadays?spring-projects-issues commentedon Oct 18, 2012
Burkhard Graves commented
@see#10737spring-projects-issues commentedon Apr 2, 2015
Juergen Hoeller commented
I can't recall what happened to this back then: We might have considered it good enough to be able to specify a custom
FormattingConversionServicethroughDataBinder.setConversionService.But point taken, a more convenient way to register specific custom formatters on a local binder instance, in addition to delegating to a shared
ConversionServicesetup, would be nice. I've reactivated #12429 and #10737 for that purpose, targeting them for 4.2.Juergen