Re: Error message

Daniel Dekany <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Wednesday, September 14, 2011, 2:25:24 PM, Shervin Asgari wrote:

>
>
> On 09/06/2011 04:30 PM, Daniel Dekany wrote:
>>
>>> However, when I put something other than null in this object, I don't
>>> get any errors.
>>>
>>> Is this a bug/feature in Freemarker? Or is it something JODReports /
>>> OpenOffice.org doing?
>> It's a feature... As I said, non-existent variables and null-s count
>> as undefined values. FreeMarker will not make guess, like something
>> that's undefined is surely like an empty string or 0 or anything like
>> that. You have to provide a default explicitly, like
>> ${maybenull!"N/A"} or even ${maybenull!} which is similar to
>> ${maybenull!""}.
>
> I see.
> But what about nested objects?
> Like lets say a we have a Person object, which has a Child object ie:
>
> person.getChild().getFirstname().
>
> Lets say the child object is null, thus getFirstname doesnt work. How 
> can we model that?
>
> ${person.child.firstname!} <-- This didnt work, nor did
> ${person!.child!.firstname!}

${(person.child.firstname)!}

> Shervin

-- 
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
Learn about the latest advances in developing for the 
BlackBerry&reg; mobile platform with sessions, labs & more.
See new tools and technologies. Register for BlackBerry&reg; DevCon today!
http://p.sf.net/sfu/rim-devcon-copy1
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.