Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-3328

make sitemesh plugin OldDecorator2NewStrutsFreemarkerDecorator configurable

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • None
    • None
    • Plugin - SiteMesh
    • None
    • Important

    Description

      struts2 supports sitemesh2.4 now, 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); }

      }

      }

      Attachments

        Activity

          People

            musachy Musachy Barroso
            quaff Yanming Zhou
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: