Bigdecimal - set to null by form when input is empty

Asked

Viewed 186 times

0

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

In the 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 doesn’t work.

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

1 answer

1


This property is for empty strings.

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

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

In the right place, as explained: in a ServletContextListener, for the property to be set before the JSF/EL is initialized.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.