You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Frederic Daoud (JIRA)" <de...@velocity.apache.org> on 2009/10/08 14:36:31 UTC

[jira] Created: (VELTOOLS-123) Layout Servlet: Look for alternate layout in request attribute

Layout Servlet: Look for alternate layout in request attribute
--------------------------------------------------------------

                 Key: VELTOOLS-123
                 URL: https://issues.apache.org/jira/browse/VELTOOLS-123
             Project: Velocity Tools
          Issue Type: Improvement
          Components: VelocityView
    Affects Versions: 1.4
            Reporter: Frederic Daoud


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.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


[jira] Commented: (VELTOOLS-123) Layout Servlet: Look for alternate layout in request attribute

Posted by "Frederic Daoud (JIRA)" <de...@velocity.apache.org>.
    [ https://issues.apache.org/jira/browse/VELTOOLS-123?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12763569#action_12763569 ] 

Frederic Daoud commented on VELTOOLS-123:
-----------------------------------------

Right, that is certainly understandable. I'm looking forward to the addition in 2.x, then. Thank you for your prompt response!


> Layout Servlet: Look for alternate layout in request attribute
> --------------------------------------------------------------
>
>                 Key: VELTOOLS-123
>                 URL: https://issues.apache.org/jira/browse/VELTOOLS-123
>             Project: Velocity Tools
>          Issue Type: Improvement
>          Components: VelocityView
>    Affects Versions: 1.4
>            Reporter: Frederic Daoud
>
> 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.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


[jira] Closed: (VELTOOLS-123) Layout Servlet: Look for alternate layout in request attribute

Posted by "Frederic Daoud (JIRA)" <de...@velocity.apache.org>.
     [ https://issues.apache.org/jira/browse/VELTOOLS-123?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Frederic Daoud closed VELTOOLS-123.
-----------------------------------


Tested, works great. Thanks Nathan! Much appreciated.


> Layout Servlet: Look for alternate layout in request attribute
> --------------------------------------------------------------
>
>                 Key: VELTOOLS-123
>                 URL: https://issues.apache.org/jira/browse/VELTOOLS-123
>             Project: Velocity Tools
>          Issue Type: Improvement
>          Components: VelocityView
>    Affects Versions: 1.4
>            Reporter: Frederic Daoud
>             Fix For: 2.0, 2.x
>
>
> 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.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


[jira] Commented: (VELTOOLS-123) Layout Servlet: Look for alternate layout in request attribute

Posted by "Frederic Daoud (JIRA)" <de...@velocity.apache.org>.
    [ https://issues.apache.org/jira/browse/VELTOOLS-123?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12781201#action_12781201 ] 

Frederic Daoud commented on VELTOOLS-123:
-----------------------------------------

Thanks again for adding this. I am using Velocity Tools in Rayures[1].
[1]: http://www.stripesbook.com/rayures.html


> Layout Servlet: Look for alternate layout in request attribute
> --------------------------------------------------------------
>
>                 Key: VELTOOLS-123
>                 URL: https://issues.apache.org/jira/browse/VELTOOLS-123
>             Project: Velocity Tools
>          Issue Type: Improvement
>          Components: VelocityView
>    Affects Versions: 1.4
>            Reporter: Frederic Daoud
>             Fix For: 2.0, 2.x
>
>
> 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.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


[jira] Commented: (VELTOOLS-123) Layout Servlet: Look for alternate layout in request attribute

Posted by "Frederic Daoud (JIRA)" <de...@velocity.apache.org>.
    [ https://issues.apache.org/jira/browse/VELTOOLS-123?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12763480#action_12763480 ] 

Frederic Daoud commented on VELTOOLS-123:
-----------------------------------------

Correction:

layout = (String) request.getAttribute(KEY_LAYOUT);


> Layout Servlet: Look for alternate layout in request attribute
> --------------------------------------------------------------
>
>                 Key: VELTOOLS-123
>                 URL: https://issues.apache.org/jira/browse/VELTOOLS-123
>             Project: Velocity Tools
>          Issue Type: Improvement
>          Components: VelocityView
>    Affects Versions: 1.4
>            Reporter: Frederic Daoud
>
> 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.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


[jira] Resolved: (VELTOOLS-123) Layout Servlet: Look for alternate layout in request attribute

Posted by "Nathan Bubna (JIRA)" <de...@velocity.apache.org>.
     [ https://issues.apache.org/jira/browse/VELTOOLS-123?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Nathan Bubna resolved VELTOOLS-123.
-----------------------------------

       Resolution: Fixed
    Fix Version/s: 2.x
                   2.0

Ok, this feature is added in 2.x.  Also, i broke the layout lookup into a separate method for easier extending.

> Layout Servlet: Look for alternate layout in request attribute
> --------------------------------------------------------------
>
>                 Key: VELTOOLS-123
>                 URL: https://issues.apache.org/jira/browse/VELTOOLS-123
>             Project: Velocity Tools
>          Issue Type: Improvement
>          Components: VelocityView
>    Affects Versions: 1.4
>            Reporter: Frederic Daoud
>             Fix For: 2.0, 2.x
>
>
> 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.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


[jira] Commented: (VELTOOLS-123) Layout Servlet: Look for alternate layout in request attribute

Posted by "Nathan Bubna (JIRA)" <de...@velocity.apache.org>.
    [ https://issues.apache.org/jira/browse/VELTOOLS-123?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12763538#action_12763538 ] 

Nathan Bubna commented on VELTOOLS-123:
---------------------------------------

Seems like a good idea.  I'll definitely add this to 2.x, but probably not the 1.x branch.  It's not likely that there will be any further releases from the 1.x branch.

> Layout Servlet: Look for alternate layout in request attribute
> --------------------------------------------------------------
>
>                 Key: VELTOOLS-123
>                 URL: https://issues.apache.org/jira/browse/VELTOOLS-123
>             Project: Velocity Tools
>          Issue Type: Improvement
>          Components: VelocityView
>    Affects Versions: 1.4
>            Reporter: Frederic Daoud
>
> 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.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org