make sitemesh plugin OldDecorator2NewStrutsFreemarkerDecorator configurable
---------------------------------------------------------------------------
Key: WW-3328
URL: https://issues.apache.org/struts/browse/WW-3328
Project: Struts 2
Issue Type: Improvement
Components: Plugin - SiteMesh
Reporter: zhouyanming
Assignee: Musachy Barroso
struts2 supports sitemesh2.4 now, https://issues.apache.org/struts/browse/WW-3291
I'd like to extends the default OldDecorator2NewStrutsFreemarkerDecorator to do something
fantastic,like compress page,render html fragment for AJAX request
I with struts provide a @Inject way.
here is sample code
public class MyOldDecorator2NewStrutsFreemarkerDecorator extends OldDecorator2NewStrutsFreemarkerDecorator
{
public static final String X_FRAGMENT = "X-FRAGMENT";
public MyOldDecorator2NewStrutsFreemarkerDecorator(Decorator oldDecorator) {
super(oldDecorator);
}
protected void render(Content content, HttpServletRequest request,
HttpServletResponse response, ServletContext servletContext,
ActionContext ctx) throws ServletException, IOException {
String replacement = request.getHeader(X_FRAGMENT);
if (replacement != null) {
StringWriter writer = new StringWriter();
content.writeBody(writer);
response.getWriter().write(HtmlUtils.compress(replacement.split(","), writer.toString()));
return;
} else {
super.render(content, request, response, servletContext, ctx);
}
}
}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
|