velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Charles Harvey III <charl...@alloy.com>
Subject Re: getting list of all context values
Date Wed, 18 Oct 2006 20:19:44 GMT
Ok.  I tried this out.  And it works... sort of.  There are definately
things missing and I can't figure out why.

As in, I know for sure that I am doing:

    request.setAttribute( "person", person );

And "person" isn't in the list of $request.attributeNames.  I can't for the
life of me figure out why though.  Is there something I am missing?  This
is what is getting printed to the page for the $request.attributeNames:

# javax.servlet.forward.request_uri
# javax.servlet.forward.context_path
# javax.servlet.forward.servlet_path
# javax.servlet.forward.path_info
# org.springframework.web.servlet.DispatcherServlet.THEME
# __acegi_session_integration_filter_applied
# org.springframework.web.servlet.DispatcherServlet.CONTEXT
# __acegi_filterSecurityInterceptor_filterApplied
# org.springframework.web.servlet.DispatcherServlet.LOCALE

What is even stranger is that it works for the session.  
$session.attributeNames:

# website
# IS_USER_ONLINE_SESSION_BINDING_LISTENER

Those are definately two values that I specifically put into the 
session.  All
I can think of is that Spring is doing something to my objects and I guess I
have to go figure out what.



Charlie



Claude Brisson said the following on 10/18/2006 4:43 AM:
> By default, the context is not included in itself, but you can still
> list the values in the session, request or response (or also in the
> servlet context, known as "application") with the following loops:
>
> #foreach($key in $request.attributeNames) ...
>
> #foreach($key in $session.attributeNames) ...
>
> #foreach($key in $application.attributeNames) ...
>
>
> If you need the context to have a key towards itself, you have to
> subclass the VelocityViewServlet, and inherit createContext like this:
>
>     protected Context createContext(HttpServletRequest request, 
>                                     HttpServletResponse response)
>     {
>        Context context = super.CreateContext(request,response);
>        context.put("context",context);
>     }
>
>
> You can then iterate on values of the context like this:
>
> <ul>
> #foreach($key in $context.keys)
> <li>$key = $context.get('$key')
> #end
> </ul>
>
> but the values in the request, session, response and application won't
> appear in this list.
>
>
>   Claude
>
> Le mardi 17 octobre 2006 à 18:18 -0400, Charles Harvey III a écrit :
>   
>> Hello.
>> If I am using the VelocityLayoutServlet where all things that I put into
>> the request, response and session automatically go into the $context.
>>
>> So... how do I get a list of all the values in the $context?  Just for
>> starters, how do I access the $context?  It is not with "$context".
>>
>> I can access $request, $response and $session.  So, how do I get at the
>> $context?
>>
>> Thanks much.
>>
>>
>> Charlie
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>>
>>     
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
>   

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


Mime
View raw message