struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joe Germuska" <>
Subject [S2] Freemarker Confusion
Date Sun, 21 Jan 2007 03:14:18 GMT
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:

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
and the syntax for testing for nulls

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.


Joe Germuska *

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

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message