This issue is however specific to EL implementation of Tomcat (Glassfish for example, doesn't expose this stupid behaviour). It used to work "as intuitively expected" until Tomcat 6.0.16. Then they discovered that it actually violated the literal EL spec and fixed it. After a lot of critism, they made it configureable from 6.0.17 and upwards. You can turn it off by adding the following VM argument:
-Dorg.apache.el.parser.COERCE_TO_ZERO=false
This is IMO better than hacking into getters/setters. You don't want to pollute your model like that.
Related questions:
- inputtext submitting value 0 instead of null
- COERCE_TO_ZERO at runtime