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
No way to register Formatter instances by field on DataBinder [SPR-6069] #10737
On DataBinder, I see you can call getFormatterRegistry().add(...). However, there is no specific binder.registerFormatter(String, Formatter<?>) callback that allows you to register a Formatter for a specific field, as an alternative to binder.registerCustomEditor(Class, String, PropertyEditor).
This one seems to be a crucial thing for us to migrate to the new infrastructure as we thend to use domain objects in the controllers as well and do not want them to be polluted with UI specific annotations.
i get what you're after.
[3/16/11 4:14:19 PM] Keith Donald: my goal has been to have stateless formatters that are configured once and can be parameterized at format time (typically via @Format annotaiton metadata)
[3/16/11 4:14:43 PM] Keith Donald: in this way there's rarely the need for a user to register custom formatters themselves in @InitBinder
[3/16/11 4:14:49 PM] Keith Donald: and that's a nice simplificaiton.
[3/16/11 4:15:05 PM] Keith Donald: in your case though, you'd like to bind directly to a domain object and not couple that object with a specific format annotation.
[3/16/11 4:15:19 PM] Keith Donald: so you'd need an extenrnalized mechanism for expressing the same field formatting rule.
I think #10839 was fixed by removing the "Registering field-specific Formatters" section.
As you point out #10684 references DataBinder.getFormatterRegistry() which doesn't seem to exist.
I'm introducing addCustomFormatter(Formatter formatter, String... fields) and addCustomFormatter(Formatter formatter, Class... fieldTypes) to DataBinder, internally adapting the given Formatter to a PropertyEditor and registering that adapter with the underlying PropertyEditorRegistry, following the usual rules there. This is a quite simple and straighforward approach which should hopefully cover the typical use case here, without having to build an extra local ConversionService underneath the covers.
Activity
spring-projects-issues commentedon Jan 13, 2010
Oliver Drotbohm commented
This one seems to be a crucial thing for us to migrate to the new infrastructure as we thend to use domain objects in the controllers as well and do not want them to be polluted with UI specific annotations.
spring-projects-issues commentedon Mar 16, 2011
Keith Donald commented
i get what you're after.
[3/16/11 4:14:19 PM] Keith Donald: my goal has been to have stateless formatters that are configured once and can be parameterized at format time (typically via
@Formatannotaiton metadata)[3/16/11 4:14:43 PM] Keith Donald: in this way there's rarely the need for a user to register custom formatters themselves in
@InitBinder[3/16/11 4:14:49 PM] Keith Donald: and that's a nice simplificaiton.
[3/16/11 4:15:05 PM] Keith Donald: in your case though, you'd like to bind directly to a domain object and not couple that object with a specific format annotation.
[3/16/11 4:15:19 PM] Keith Donald: so you'd need an extenrnalized mechanism for expressing the same field formatting rule.
spring-projects-issues commentedon Oct 22, 2012
Donnchadh O Donnabhain commented
Any further thoughts on this and #12429?
spring-projects-issues commentedon Oct 23, 2012
Burkhard Graves commented
Yes, I wonder too. Moreover, this seems to be related to #10684 and #10839 - and both tasks are marked as 'solved'?! I don't get it...
spring-projects-issues commentedon Oct 23, 2012
Donnchadh O Donnabhain commented
I think #10839 was fixed by removing the "Registering field-specific Formatters" section.
As you point out #10684 references
DataBinder.getFormatterRegistry()which doesn't seem to exist.spring-projects-issues commentedon Oct 23, 2012
Burkhard Graves commented
Ah, ok, now I understand why #10839 was closed (by the way, I found http://static.springsource.org/spring/previews/ui-format.html#ui-format-registering-field-specific-Formatters - should be better removed by the spring team, I think ;-)).
But I still don't understand why #10684 was closed...
spring-projects-issues commentedon May 12, 2015
Juergen Hoeller commented
I'm introducing
addCustomFormatter(Formatter formatter, String... fields)andaddCustomFormatter(Formatter formatter, Class... fieldTypes)toDataBinder, internally adapting the givenFormatterto aPropertyEditorand registering that adapter with the underlyingPropertyEditorRegistry, following the usual rules there. This is a quite simple and straighforward approach which should hopefully cover the typical use case here, without having to build an extra localConversionServiceunderneath the covers.Juergen