I have created a custom string converter for spring webflow that trims spaces for every String property
public class StringTrimmerConverter implements Converter {
public Object convertSourceToTargetClass(final Object object, final Class clazz) throws Exception {
if ((object != null) && (object.getClass() == getSourceClass()) && (clazz == getTargetClass())) {
return ((String) object).trim();
}
return object;
}
public Class<String> getSourceClass() { return String.class; }
public Class<String> getTargetClass() { return String.class; }
}
It is added in conversion services
public class FlowConversationService extends DefaultConversionService {
protected void addDefaultConverters() {
super.addDefaultConverters();
this.addConverter(new StringTrimmerConverter());
}
}
Is there a way to disable this converter for password fields only?
I'm using spring webflow 2.3.2.RELEASE and spring 3.2.2.RELEASE.
You can force a specific converter with <binding>
configuration.
Alternatively you can store password field in char[]
. I had discussions with people which prefer this over String
as char array will not get interned.