Uploaded image for project: 'Velocity Tools'
  1. Velocity Tools
  2. VELTOOLS-123

Layout Servlet: Look for alternate layout in request attribute

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.4
    • Fix Version/s: 2.0, 2.x, 3.0
    • Component/s: VelocityView
    • Labels:
      None

      Description

      The layout servlet looks for an alternate layout in the request parameters, and in the context (e.g. #set($layout="...").

      It would be very useful if it would also look in the request attributes, e.g. request.getAttribute("layout"). This would allow a servlet filter to specify which layout to use, according to whatever criteria, by setting the layout as a request attribute.

      This improvement is very easy to add, and it would be oh so useful!

      VelocityLayoutServlet.java (1.4):

      protected Context createContext(HttpServletRequest request,
      HttpServletResponse response)
      {

      Context ctx = super.createContext(request, response);

      // check if an alternate layout has been specified
      // by way of the request parameters
      String layout = request.getParameter(KEY_LAYOUT);

      // also look in the request attributes
      if (layout == null)

      { layout = request.getAttribute(KEY_LAYOUT); }

      if (layout != null)

      { // let the template know what its new layout is ctx.put(KEY_LAYOUT, layout); }

      return ctx;
      }

      Thanks in advance.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              fdaoud Frederic Daoud
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: