If you're interested in functional programming, you might also want to checkout my second blog which i'm actively working on!!

Wednesday, September 22, 2010

Unwanted behaviour with Numeric converters in JSF

It seems that you have to be carefull as what to expect from the standard JSF converters. Let us take a look at following jsf snippet which should convert the value entered into a java.lang.Long.



It does a good job if the user enters something that is not convertible to a long.












However, when you enter nothing and leave the Job ID field blank, JSF does a not so nice job of converting the value to 0 (zero) while you were expecting a null value.

Check out following articles as well as how-to solve this:

http://balusc.blogspot.com/2008/07/dao-tutorial-use-in-jsf.html#EmptyToNullConverter
http://tomcat.apache.org/tomcat-6.0-doc/config/systemprops.html#Expression_Language


I tested with the solution from BalusC's blog but a custom converter didn't even help solving the issue on tomcat6.


So the option left is to add following startup parameter to tomcat's launch configuration and use the standard jsf converter as mentioned on top of this article.

No comments:

Post a Comment