Hi,
I have an input box that takes a number - a simple int. This box corresponds to a db column that accepts null values. I'd like to send null to DAO layer when user enters nothing (empty
string).
The problem is that
JSF automatically converts empty string to zero (int). I tried to provide my own converter, and I can convert the empty string into any value (say, -1 for example) but still not null! When my converter returns null DAO receives again zero.
I tried one more thing - marking the field as required and providing my own validator (that would ignore empty string):
<h:inputText id="canBeNull" value="#{controller.someField}" required="true">
<f:validator validatorId="myIntValidator"/>
<f:converter converterId="myIntConverter"/>
</h:inputText>
But here I ran into yet another problem: for some reason my validator is ignored and I always get a message "field required blah blah ...".
Does anyone know how to send that null to the db? I'm not sure what to try next ...
Thanks,
Bratek