2

As I read here:

http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/portlet.html#portlet-ann-webdatabinder

And as I saw in some other question like this one, I'm registering a StringTrimmerEditor in my controller like this:

@Controller
public class MyController{


    @InitBinder
     public void initBinder(WebDataBinder binder) 
     {
       binder.registerCustomEditor(StringTrimmerEditor.class,new  StringTrimmerEditor(false));
     }

It compiles and runs, but does not work, it doesn't trim the data. I don't know what am I missing. Anyone?

thanks

Community
  • 1
  • 1
de3
  • 1,890
  • 5
  • 24
  • 39

1 Answers1

9

javadoc to the rescue:

public void registerCustomEditor(Class requiredType, PropertyEditor propertyEditor)

Description copied from interface: PropertyEditorRegistry
Register the given custom property editor for all properties of the given type.

Specified by:
    registerCustomEditor in interface PropertyEditorRegistry

Parameters:
    requiredType - the type of the property
    propertyEditor - the editor to register

The class should not be the class of the editor.It should be the type of the fields on which you want the editor to apply: String.class

JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255
  • I have to admit I was lazy yesterday at that late time at night, so instead of researching I rather asked here, expecting to have an answer today in the morning. – de3 Dec 28 '11 at 14:57