este doplnim, tu je cely problem celkom pekne popisany:

http://opensource.atlassian.com/confluence/spring/display/DISC/java.lang.Integer+properties+of+Command+objects

kde je popisane aj nasledovne: "Spring provides a CustomerNumberEditor^ <http://www.springframework.org/docs/api/org/springframework/beans/propertyeditors/CustomNumberEditor.html> for converting Strings to Numbers, such as java.lang.Integer. Note that CustomNumberEditor will convert to all subclasses of java.lang.Number. Spring does *not* wire this property editor automatically because it is meant to be configured with a Locale. Each web request may provide a different Locale (depending on the client), which forces the setup of CustomNumberEditor to be performed at request time."

Ivan

Ivan Polák  wrote / napísal(a):
vygooglil som zatial toto:

I have some default binding error messages configured for scenarios where a form values can't be bound. For example, when a string in the form can't be bound to a Long value. A subset of my messages.properties looks like:

typeMismatch.java.lang.Integer=Must specify an integer value.
typeMismatch.java.lang.Long=Must specify an integer value.
typeMismatch.java.lang.Float=Must specify a decimal value.
typeMismatch.java.lang.Double=Must specify a decimal value.

takze v resource bundle (messages.properties) staci prepisat tieto hlasky ako potrebujem. vyskusal som a funguje.

property mam typu Integer.

Ivan


Karel Tejnora  wrote / napísal(a):
Jen tak od boku; Tohle se mi stava pri validaci, kdyz property je typu
"int" nikoliv java.lang.Integer (nebo setAge(Integer age) vyhodi vyjimku
NullPointerException)

Failed to convert property value of type [java.lang.String] to required type
[java.lang.Integer] for property age; nested exception is
java.lang.NumberFormatException: For input string: "aaa"









Odpovedet emailem