struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Gilday (JIRA)" <>
Subject [jira] Commented: (WW-1808) Support Freemarker template_exception_handler=rethrow
Date Sat, 05 May 2007 13:07:43 GMT


Martin Gilday commented on WW-1808:

I have created a patch for the same issue in WebWork 2.2.5, using a slightly different method.
See [1] for the patch and [2] for the WebWork forum posting.


It should be trivial to apply the same patch to Struts2, assuming the FreemarkerResult has
not changed too much between projects.  I wouldn't have thought it has.

We are currently developing a new app using WW2.2.5 so we will be giving this a thorough testing
over the next week.

> Support Freemarker template_exception_handler=rethrow
> -----------------------------------------------------
>                 Key: WW-1808
>                 URL:
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Views
>    Affects Versions: 2.0.6
>            Reporter: Jasper Rosenberg
>            Priority: Minor
>             Fix For: 2.1.0
> If you set in, the property:
> template_exception_handler=rethrow
> Then you do not want the FreemarkerResult to output to the Writer unless you know the
template processed cleanly (so you can handle the exception and go to a nice error page rather
than being stuck with half rendered template output).
> My suggestion is to add a new parameter to FreemarkerResult, something like "writeCompleted"
which defaults to false and, if true, renders the template into a String buffer, writing the
result to the actual Writer only if it succeeded.
> Something like:
> // Process the template
> Writer writer = getWriter();
> if (getWriteCompleted()) {
>     CharArrayWriter charArrayWriter = new CharArrayWriter();
>     template.process(model, charArrayWriter);
>     charArrayWriter.flush();
>     charArrayWriter.writeTo(writer);
> } else {
>     template.process(model, writer);
> }

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message