struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joe Germuska" <...@germuska.com>
Subject Re: [S2] Freemarker Confusion
Date Sun, 21 Jan 2007 04:57:56 GMT
Tom:

Thanks for your help...  I see now that the syntax I was trying to use was
added in Freemarker 2.3.7

http://freemarker.sourceforge.net/docs/versions_2_3_7.html

Now... is an empty string the right result?  maybe ${error?default("<!--
null error -->")} ?

is that overkill?

Joe

On 1/20/07, Tom Schneider <schneidh@gmail.com> wrote:
>
> Joe,
> ${error} being null would imply that you have an item in the action
> errors Collection that is null.  (e.g. {"Error1", "Error2", null,
> "Error4})  It seems like that would be an issue that occurs as the
> errors are being populated.  (I can't think of a valid use case where
> you would have a null error message.)
>
> In spite of that, you could modify the template to handle this more
> gracefully using the default function:
>   <li><span class="errorMessage">${error?default("")}</span></li>
>
> In general, I think there is room for improvement in the UI tags error
> handling/reporting.  I've already submitted patches for null handling in
> the select tags--this is just another instance were nulls slip through
> the cracks.
> Tom
>
> Joe Germuska wrote:
> > 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
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>


-- 
Joe Germuska
Joe@Germuska.com * http://blog.germuska.com

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

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