If you register the property editor in the controller, it looks like this:
Code:
@Override
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder)
throws ServletException {
binder.registerCustomEditor(MyObject.class, new MyObjectEditor());
..
}
and then the editor
Code:
public class MyObjectEditor extends PropertyEditorSupport {
@Override
public String getAsText() {
if(getValue() instanceof MyObject) {
MyObject d = (MyObject)getValue();
return d.getId().toString();
} else if(getValue() instanceof Long) {
return getValue().toString();
}
return "-";
}
@Override
public void setAsText(String text) throws IllegalArgumentException {
MyObject cat = null;
if(!text.equals("-")) {
..
}
setValue(cat);
}
}
Your actual implementation depends on your needs.
I hope this helps.