Solution to “f:validateRequired doesn’t work”

less than 1 minute read

I found this problem on my JSF application running on Tomcat: the  didn’t work: When I let the input field empty and submit, no validation message shown and the field value became zero automatically.

Solution:

1) Tomcat convert null value to Zero automatically, so add this JVM option to catalina.sh: -Dorg.apache.el.parser.COERCE_TO_ZERO=false

2) JSF doesn’t validate empty field by default! Set this context parameter, javax.faces.VALIDATE_EMPTY_FIELDS, to true in web.xml

 

Categories: Tech

Updated: