BigDecimal - set to null by form when input is empty

0

I have a form (jsf / primefaces) where a value of type BigDecimal , can be submitted without value. In this case, the value of it should be null . However, when set, it will be 0 . There is an argument that is passed to vm by JBOSS which makes the value set to null but this solution is not interesting for me.

No web.xml is defined:

<context-param>
    <param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
    <param-value>true</param-value>
</context-param>

But it still does not work.

Is there any way to implement this by continuing the attribute to be BigDecimal ?

    
asked by anonymous 29.10.2016 / 22:46

1 answer

1

This property is for empty strings.

For numbers you need to set the COERCE_TO_ZERO property to false , as says in this answer .

Just set the property this way: System.setProperty("org.apache.el.parser.COERCE_TO_ZERO", "false");

In the correct place, as explained: in ServletContextListener , so that the property is set before JSF/EL is initialized.

    
01.11.2016 / 19:01