Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSF2.0 Blank Input field in is not setting as NULL

Tags:

java

jsf

jsf-2

I have a backing bean where filelds are Long , Double , Integer , String When I am not specifying anything in input field it is taking as zero for Long, Integer and Double instead of null. I am using tomcat to deploy my app. Is there any solution? I have tried the following context parameter, but it does not work.

<context-param>
    <param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
    <param-value>true</param-value>
</context-param>
like image 827
Arvind Avatar asked May 23 '11 13:05

Arvind


1 Answers

Add the following VM argument to Tomcat startup options.

-Dorg.apache.el.parser.COERCE_TO_ZERO=false

You also need to ensure that you've declared faces-config.xml conform the JSF 2.0 specification.

<?xml version="1.0" encoding="UTF-8"?>
<faces-config
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
    version="2.0">
    <!-- Your config here -->
</faces-config>

Otherwise JSF 2.0 specific settings/features won't be activated.

like image 91
BalusC Avatar answered Oct 30 '22 13:10

BalusC