I identified the issue and this isn't related to NULL references. To
summarize:

This syntax will work with a getter method OR directly with the raw member
variable if the getter method isn't present: <@s.property
value="myActionProperty.subProperty" />

This syntax requires a getter method and won't work directly with a member
variable: ${myActionProperty.subProperty}


I prefer to avoid littering my code with unnecessary boilerplate
getter/setter methods and only define getters/setters when they actually do
something that is non-trivial. But at least this makes sense.

Thank you very much for the helpful replies!


Zarar Siddiqi wrote:
> 
> Freemarker considers null references errors.  When
> myActionProperty.subProperty is referenced in the Struts tag, it is
> printed regardless of its value.  However, when Freemarker encounters
> ${myActionProperty.subProperty}, it will give you an error if
> subProperty is null.  When trying to print Freemarker variables using
> the $ or # syntax, you should probably do an if check like this:
> 
> <# if myActionProperty.subProperty?exists>
>   ${myActionProperty.subProperty}
> </#if>
> 
> I know, it's a bit of a pain.
> 
> Zarar Siddiqi
> 

-- 
View this message in context: 
http://www.nabble.com/Simple-Question-about-FreeMarker-%2B-Struts-2-tf4394620.html#a12619549
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to