How to receive null value from the view
Good development practices say: “avoid passing null values inside your application”; following this good practice we will be reducing the possibility of the famous NullPointerException. By default the JSF will handle all requests parameters to be not null. An integer will be equals to zero, a Boolean to false and a String will be “” (empty but not null).
If the business rule is to receive null instead some default value, there is a way to notify the JSF to do not provide the default values. The first step is to add the configuration below to the web.xml file.
<context-param> <param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name> <param-value>true</param-value> </context-param>
If the application is running in the Glassfish container just the configuration above will complete the task. If the application is running in the Tomcat/JBoss, this configuration alone will not be enough to bring the value as null. This happens because the Tomcat/JBoss will ignore the configuration. To force the container to “respect” the configuration add the following configuration to the container JVM: -Dorg.apache.el.parser.COERCE_TO_ZERO=”false”. The Tomcat/JBoss will keep the empty value as null and will not provide the default JSF values.