jsf: integer property binded to a inputtext in UI is set to zero on submit

changed picture changed · Dec 27, 2010 · Viewed 13.3k times · Source

I have integer properties from my bean binded to inputtext UI elements in jsp pages.

initially when they are rendered, default value of this integer properties is null.

Now when i am submitting the form without changing this inputtext fields, this fields are set to integer value zero in bean, even though ui text field is blank.

As i want to track the changes to fields and update only those fields which are changed in configuration files, but this is giving me problem as it results into updates to all integer field.

I am using jsf 1.2

Answer

BalusC picture BalusC · Dec 28, 2010

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: