You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Barclay Dunn <bd...@emeta.com> on 2004/07/20 18:19:52 UTC
Re: Re: How to iterator all incoming parameters in Velocity Templ
ate ?
hi all,
i have the same issue as discussed earlier by Xiaogang Cao and Geir
Magnusson Jr, except i do not have the ability to control the incoming
parameters. i need to iterate through them to see what is being sent in. is
there any way to do this? i tried accessing the context object directly
(i.e., $context) which did not work. i have read through all the
documentation but there's nothing in there about this.
any help would be greatly appreciated. i'm used to jsps.
barclay
On May 12, 2004, at 06:42:19 -0700, Geir Magnusson Jr wrote:
Re: How to iterator all incoming parameters in Velocity Template ?
----------------------------------------------------------------------------
----
From: Geir Magnusson Jr
Subject: Re: How to iterator all incoming parameters in Velocity
Template ?
Date: Wed, 12 May 2004 06:42:19 -0700
----------------------------------------------------------------------------
----
On May 12, 2004, at 12:11 AM, Xiaogang Cao wrote:
Hi, dear all:
I'm a newbie for Velocity.
<snip>
New I havea problem , how can I iterate all incoming
parameters in vm file?
Do you mean incoming parameters in the HttpServletRequest?
such as:
context.put("key1","value1") ;
context.put("key2","value2") ;
context.put("key3","value3") ;
I need to write:
<li>key1</li><code>value1</code>
<li>key2</li><code>value2</code>
<li>key3</li><code>value3</code>
Ah - stuff them in a map :
Map m = new HashMap();
m.put("key1", "value1");
....
context.put("data", m);
then
#foreach($key in $m.keySet())
$key $m.get($key)
#end
I think that
#foreach($k in $m)
will work well - that we iterate over the keyset naturally, but I'd
have to check...
geir
--
Geir Magnusson Jr 203-247-1713(m)
[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: How to iterator all incoming parameters in Velocity Templ ate
?
Posted by Simon Christian <si...@stoutstick.com>.
Hi Barclay,
I presume you're referring to the form parameters here, as opposed to
what's being put into the context by the controller servlet/action/whatever.
If the ServletRequest is available in your context (it would be by
default using VVS or VLS for instance), you can access the names of the
parameters using the JSDK API, by - assuming the request is in the
context as the variable $request - calling:
$request.ParameterNames
or to explitly state the method:
$request.getParameterNames()
This method (from the javadocs) "Returns an Enumeration of String
objects containing the names of the parameters contained in this request."
- simon
Barclay Dunn wrote:
> hi all,
>
> i have the same issue as discussed earlier by Xiaogang Cao and Geir
> Magnusson Jr, except i do not have the ability to control the incoming
> parameters. i need to iterate through them to see what is being sent in. is
> there any way to do this? i tried accessing the context object directly
> (i.e., $context) which did not work. i have read through all the
> documentation but there's nothing in there about this.
>
> any help would be greatly appreciated. i'm used to jsps.
>
> barclay
>
> On May 12, 2004, at 06:42:19 -0700, Geir Magnusson Jr wrote:
>
> Re: How to iterator all incoming parameters in Velocity Template ?
>
> ----------------------------------------------------------------------------
> ----
> From: Geir Magnusson Jr
> Subject: Re: How to iterator all incoming parameters in Velocity
> Template ?
> Date: Wed, 12 May 2004 06:42:19 -0700
>
> ----------------------------------------------------------------------------
> ----
> On May 12, 2004, at 12:11 AM, Xiaogang Cao wrote:
> Hi, dear all:
> I'm a newbie for Velocity.
> <snip>
> New I havea problem , how can I iterate all incoming
> parameters in vm file?
>
> Do you mean incoming parameters in the HttpServletRequest?
>
> such as:
> context.put("key1","value1") ;
> context.put("key2","value2") ;
> context.put("key3","value3") ;
> I need to write:
> <li>key1</li><code>value1</code>
> <li>key2</li><code>value2</code>
> <li>key3</li><code>value3</code>
>
> Ah - stuff them in a map :
>
> Map m = new HashMap();
> m.put("key1", "value1");
> ....
> context.put("data", m);
>
> then
>
> #foreach($key in $m.keySet())
> $key $m.get($key)
> #end
>
> I think that
> #foreach($k in $m)
> will work well - that we iterate over the keyset naturally, but I'd
> have to check...
>
> geir
> --
> Geir Magnusson Jr 203-247-1713(m)
> [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> 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