Announcement Announcement Module
No announcement yet.
Implementing a String trimming converter Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Implementing a String trimming converter

    Hi all,

    I'd like to create a converter that basically calls String.trim() on String properties. With Spring MVC, this is achieved simply by registering a custom PropertyEditor which will automatically be applied to all Strings. I cannot see an equivalent in Web Flow, and I am wondering whether I am missing something.

    I have tried subclassing the DefaultConversionService class to add custom converters, and while my other String -> Object converters work, my String -> String converter is never called.

    I realise that I should be able to select a converter by ID if I specify all my bindings explicitly in my flow definition, but since I would then need to specify every one of my bindings, it seems like an awful amount of XML to achieve this.

    Any pointers would be appreciated


  • #2
    Incidentally, in my DefaultConversionService subclass, I did try overriding the getConversionExecutor(Class, Class) method to avoid the logic in lines 132-134 of DefaultConversionService (the part that says that if the source and target classes are the same, then return a NoOpConverter). However, it appears that when this method is called, the relevant ConversionService implementation is actually an instance of GenericConversionService rather than any of its subclasses, so the overriden implementation is irrelevant.