L
liu
Recently I had some quality frustration time with Struts 1.1
validation on integer, long, etc. Since I pass the whole Data Transfer
Object into the dynaValidatorForm, it is not easy for me to set Long
parameter to String and do conversion in Action class. By default
configuration, even though I set up the validation to be "required,
long", the validator did not block invalid input and caused exception.
I found Greg Williams ([email protected]) had the same
problem.
In Struts document, there is a paragraph:
Note: If your required form property is one of the Java object
representations of primitive types (ie. java.lang.Integer), you must
set the ActionServlet's convertNull init. parameter to true. Failing
to do this will result in the required validation not being performed
on that field because it will default to 0.
After I add the parameter "convertNull" in web.xml, I have everything
behaving as expected.
validation on integer, long, etc. Since I pass the whole Data Transfer
Object into the dynaValidatorForm, it is not easy for me to set Long
parameter to String and do conversion in Action class. By default
configuration, even though I set up the validation to be "required,
long", the validator did not block invalid input and caused exception.
I found Greg Williams ([email protected]) had the same
problem.
In Struts document, there is a paragraph:
Note: If your required form property is one of the Java object
representations of primitive types (ie. java.lang.Integer), you must
set the ActionServlet's convertNull init. parameter to true. Failing
to do this will result in the required validation not being performed
on that field because it will default to 0.
After I add the parameter "convertNull" in web.xml, I have everything
behaving as expected.