I have a question regarding JSF conversion. I have an input text define like this:
<p:inputText size="15" maxlength="11" value="#{user.SSN}"/>
backing bean:
private Integer SSN;
From this site:
http://laliluna.com/articles/posts/javaserver-faces-converter-tutorial.html
I understand that JSF has built in converters for Integers.
“If you don’t specify a converter, JSF will pick one for you. The framework has standard converters for all of the basic types: Long, Byte, Integer, Short, Character, Double,
Float, BigDecimal, BigInteger and Boolean.. For example, if your component is associated with a property of type boolean, JSF will choose the Boolean converter. Primitive types are automatically converted to their object counterparts.”
however when I execute the above code, I got this error:
j_idt78: '99999999999' must be a number consisting of one or more digits.
What is wrong with my understanding this concept? Why doesn’t JSF uses its standard converters in this case?
Not completely sure but I am positive that the number 99999999999 is far too large to be stored as an Integer, so instead it defaults to treat it like a String.
If you change the field SSN to a
LongorBigIntegerthen it will probably work correctly. Optionally you can explicitly specify a number converter for this field directly by adding the following Facelets tag inside of the Primefaces tag<f:convertNumber>http://docs.oracle.com/javaee/5/javaserverfaces/1.2/docs/tlddocs/f/convertNumber.html