huijzer
Apr 27th, 2006, 09:00 AM
Hi all,
I have registered a CustomNumberEditor in my Controller that enables me to have optional Integer properties.
protected void initBinder(HttpServletRequest request,
ServletRequestDataBinder binder) throws Exception {
PropertyEditor editor = new CustomNumberEditor(Integer.class, true);
binder.registerCustomEditor(Integer.class, "year", editor);
}
Everything works as expected, but when I type an invalid value in the HTML form, I get the following error message shown in my form:
Failed to convert property value of type [java.lang.String] to required type [java.lang.Integer] for property year; nested exception is java.lang.NumberFormatException: For input string: "invalid"
Is there a way that I can override this message and have a error message from my messages.properties (I have this configured in a MessageSource bean) file shown?
Thanks in advance,
Arjan Huijzer
I have registered a CustomNumberEditor in my Controller that enables me to have optional Integer properties.
protected void initBinder(HttpServletRequest request,
ServletRequestDataBinder binder) throws Exception {
PropertyEditor editor = new CustomNumberEditor(Integer.class, true);
binder.registerCustomEditor(Integer.class, "year", editor);
}
Everything works as expected, but when I type an invalid value in the HTML form, I get the following error message shown in my form:
Failed to convert property value of type [java.lang.String] to required type [java.lang.Integer] for property year; nested exception is java.lang.NumberFormatException: For input string: "invalid"
Is there a way that I can override this message and have a error message from my messages.properties (I have this configured in a MessageSource bean) file shown?
Thanks in advance,
Arjan Huijzer