Skip to content

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

Closed

Description

@spring-projects-issues

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

Activity

  1. spring-projects-issues commented on Aug 24, 2009

    @spring-projects-issues
    CollaboratorAuthor

    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

  2. spring-projects-issues commented on Jul 20, 2010

    @spring-projects-issues
    CollaboratorAuthor

    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

  3. spring-projects-issues commented on Oct 18, 2012

    @spring-projects-issues
    CollaboratorAuthor

    Burkhard Graves commented

    Albeit this task is more than two years old: Are there any news concerning the registration of "field-specific" formatters?

    --dhukas

  4. spring-projects-issues commented on Oct 18, 2012

    @spring-projects-issues
    CollaboratorAuthor

    Oliver Drotbohm commented

    As the ticket says, released in Spring 3.0 RC1.

  5. spring-projects-issues commented on Oct 18, 2012

    @spring-projects-issues
    CollaboratorAuthor

    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?

  6. spring-projects-issues commented on Oct 18, 2012

    @spring-projects-issues
    CollaboratorAuthor

    Burkhard Graves commented

    @see #10737

  7. spring-projects-issues commented on Apr 2, 2015

    @spring-projects-issues
    CollaboratorAuthor

    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

Metadata

Metadata

Assignees

Labels

type: enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions