Ronald Haring
unread,Jul 29, 2012, 5:09:54 AM7/29/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to play-fr...@googlegroups.com
Hello all,
I would like to register a custom editor so that each empty string will be converted to a null value in my model. I tried registering a formatter in the global java file, but when I put a breakpoint on this formatter I see that this is only called if the content of the property is filled. How can I register a custom editor so that an empty value will be nullified?
This is what I have now:
public void onStart(Application app) {
Formatters.register(String.class, new Formatters.SimpleFormatter<String>() {
@Override
public String parse(String text, Locale locale) throws ParseException {
text = text.trim();
if (text.isEmpty()) {
text = null;
}
return text;
}
@Override
public String print(String s, Locale locale) {
return s.trim();
}
});
}
Regards
Ronald