Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Formatter support to DataBinder [SPR-6015] #10684

Closed
spring-projects-issues opened this issue Aug 17, 2009 · 7 comments
Closed

Add Formatter support to DataBinder [SPR-6015] #10684

spring-projects-issues opened this issue Aug 17, 2009 · 7 comments
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Aug 17, 2009

Keith Donald opened SPR-6015 and commented

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.

New proposed methods:
registerFormatter(Class type, Formatter formatter); registerFormatter(Class type, String field, Formatter formatter);
setFormatterRegistry(FormatterRegistry);


Issue Links:

Referenced from: commits 20f5f99

@spring-projects-issues
Copy link
Collaborator Author

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 @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.

Juergen

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented 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 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?

Regards,
Ollie

@spring-projects-issues
Copy link
Collaborator Author

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
Copy link
Collaborator Author

Oliver Drotbohm commented

As the ticket says, released in Spring 3.0 RC1.

@spring-projects-issues
Copy link
Collaborator Author

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 @Initbinder nowadays?

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Oct 18, 2012

Burkhard Graves commented

@see #10737

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented 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 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.

Juergen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants