This "feature" was result of a bugfix in EL which was introduced as per Tomcat 6.0.16. As per chapter 1.18.3 of the EL specification, a value of number type which is null
should be coerced to 0. Before Tomcat 6.0.16 this was "incorrectly" been coerced to an empty string.
After all, an empty string was actually much more intuitive than a zero. The Tomcat guys at Apache got a lot complaints about this bugfix, so they introduced a new configuration setting in flavor of a VM argument as per Tomcat 6.0.17 which would disable this bugfix.
-Dorg.apache.el.parser.COERCE_TO_ZERO=false
I've by the way requested a change to this spec that it should only coerce empty/null primitive types to zero and empty/null non-primitive java.lang.Number
types to empty string: JSP EL issue 184. They did not much with it, but the issue at least got a lot of votes. Who knows... This behaviour is at least indeed pretty annoying because it's non-intuitive.
See also:
<p:inputNumber/>
and our component kept returning 0 on empty input value. It turned out,emptyValue
attribute on<p:inputNumber/>
caused that issue (even when it was empty - e.g.emptyValue=""
). After having removedemptyValue
attribute (stopped declaring it in<p:inputNumber/>
) everything works fine. – Dagny