I've ran into an odd problem of my own and while I'm troubleshooting it, I'm
hitting some problems or confusion with Freemarker as it is used for the S2
UI tags.  Can anyone help me understand this better?

I was getting a big yellow and red Freemarker trace in my rendered page
because an ${error} expression yielded null when using <s:actionerror>.
I'm assuming this is the result of an uncaught NullPointerException being
caught by Struts2, as the message for NPEs is often itself null.  I actually
haven't yet figured out where this logic is, so question 1 is "which class
is actually catching my exception and routing to an 'error' page?"

Then, it seems like our templates should be prepared for the possibility of
a null message, especially if they are being invoked when an unexpected NPE
is caught -- a not unlikely scenario.

So I found this page of Freemarker documentation explaining how to deal with
empty values:

http://freemarker.sourceforge.net/docs/dgui_template_exp.html#dgui_template_exp_missing

except that it doesn't seem to apply to the version of Freemarker (2.3.4)
that we're using.  They're only up to 2.3.8 and they make a big fuss about
nulls -- can this be new just in those minor releases?  Or is there
something I should understand about why those rules don't apply to
Freemarker as it is used in S2?  I get an error when I try to use the syntax
for handling missing values
 ${error!"null"}
and the syntax for testing for nulls
 ${error??}

What am I missing?

After I get all that cleared up, the last question is whether or not we
ought to make a change to template/simple/actionerror.ftl so that it handles
this gracefully.  I guess I already think the answer is "yes", and I'd do it
myself, except apparently I haven't found Freemarker syntax documentation
which is right for our environment.

Thanks
 Joe

--
Joe Germuska
[EMAIL PROTECTED] * http://blog.germuska.com

"The truth is that we learned from João forever to be out of tune."
-- Caetano Veloso

Reply via email to