I have a JSF 2.0 application on Tomcat with many <h:inputText> fields to input data in my database. Some fields are not required.
<h:inputText value="#{registerBean.user.phoneNumber}" id="phoneNumber">
<f:validateLength maximum="20" />
</h:inputText>
When the user leave this field empty JSF sets empty string "" instead of null.
How can I fix this behavior without checking every String with
if (string.equals("")) { string = null; }