|
|
|
FYI, the relevant FreemarkerResult code had actually changed a bit in Struts 2 from WW 2.2.4.
The reason I suggested adding a parameter for this behavior rather than just always writing to a buffer first is that I didn't want users that weren't using rethrow to have to have this extra overhead for every page rendered. We have been using my suggested patch in production for months (originally with WW 2.2.4), and it behaves as desired. Ah I see. Sorry Jasper, I didn't see where writeCompleted was set. Kind of obvious now I read it again. Have you investigated if it is possible to have the param set based on what is set in freemarker.properties to avoid the duplication in xwork.xml/struts.xml ?
That is an excellent point. Perhaps instead of checking getWriteCompleted() (or in addition to it), in FreemarkerResult, we can just check the exception handler on the configuration:
if (configuration.getTemplateExceptionHandler() == TemplateExceptionHandler.RETHROW_HANDLER) { CharArrayWriter charArrayWriter = new CharArrayWriter(); template.process(model, charArrayWriter); charArrayWriter.flush(); charArrayWriter.writeTo(writer); } else { template.process(model, writer); } This handles this most common case, but we might still want the optional parameter in case someone wants to use their own TemplateExceptionHandler that also requires the same behavior for FreemarkerResult. Thanks for the feedback and the patch guys!
|
||||||||||||||||||||||||||||||||||||||||||
See [1] for the patch and [2] for the WebWork forum posting.
[1] http://jira.opensymphony.com/browse/WW-1458
[2] http://forums.opensymphony.com/thread.jspa?threadID=81479
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.