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 14:57:49 GMT
Thanks Claude for the suggestion.  I will do exactly as you said and I
am certain that it will work.

As for having a tool, that would be spectacular.

What we have happen here is the that java developers do what they have 
to do.
Then the site gets passed to HTML developers.  Each of which is quite
proficient in Velocity, so it works out well.  But what they don't know
is all the variables that they can use on each page.

So, on my development server I will have a <div> at the bottom of my page
that lists out all of the context values.  That way the HTML developers have
a reference for each page they need to develop.


Thanks again for the help.


Charlie


Nathan Bubna said the following on 10/18/2006 10:49 AM:
> This gives me an interesting idea.  Perhaps we (someone) could write a
> ContextTool that would be able to return a list of all available
> values even in a ViewContext (i.e. one that chains request, session,
> and application attributes).  That would make it so you only need to
> add the tool to your toolbox, rather than subclass the servlet.
>
> It shouldn't be difficult.  Perhaps i'll do it today if i need a break
> from other things.
>
> On 10/18/06, Claude Brisson <claude@renegat.net> wrote:
>> 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
>
>

---------------------------------------------------------------------
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