Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 767
changed Avatar asked Dec 27 '10 20:12

changed


1 Answers

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
like image 193
BalusC Avatar answered Sep 28 '22 03:09

BalusC