Re: Handling null values

Daniel Dekany <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Friday, August 15, 2008, 2:23:17 PM, koevet wrote:

> Hello, I have just started using Freemarker.
>
> I have a basic problem. How do I set the template to handle null values of
> an int field of a pojo as String and display no values? 
> Currently my template looks like:
>
> Event: "${event.eventSource!""}","${event.eventType!""}
>
> eventType is a int field of a pojo. If the field is null, Freemarker
> displays 0 (default for int). I would like to change the behavior to display
> an empty String. And no, I can't change the type to Integer.

The ${event.eventSource!""} expression clearly tells FreeMarker that
the default value is an empty string, not 0. Also, FreeMarker nowhere
uses 0 as default for numbers. So, I guess, the interpretation of the
missing value as 0 happens on some other level.

> Thanks
> Luciano

-- 
Best regards,
 Daniel Dekany


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.