It's something really simple but I couldn't find a good example:
I have a custom data type that I'd like to bind to a SpringMVC checkbox, it looks like this: YES/NO:
public enum YesNoDataType {
YES("Yes"),
NO("No");
}
SpringMVC checkboxes auto-map to Booleans, now I need to map Selected->YES, Empty->NO.
I know I have to implement one of these 4 PropertyEditorSupport methods, but which ones, and how?
<form:checkbox path="testYesNo"></form:checkbox>
Model
private YesNoDataType testYesNo;
Controller
binder.registerCustomEditor(YesNoDataType.class, new PropertyEditorSupport() {
// Which ones to override?
@Override
public void setValue(Object value) {
// TODO Auto-generated method stub
super.setValue(value);
}
@Override
public Object getValue() {
// TODO Auto-generated method stub
return super.getValue();
}
@Override
public String getAsText() {
// TODO Auto-generated method stub
return super.getAsText();
}
@Override
public void setAsText(String text) throws IllegalArgumentException {
// TODO Auto-generated method stub
super.setAsText(text);
}
});