You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Xiaogang Cao <ca...@beacontech.cn> on 2004/05/12 06:11:56 UTC

How to iterator all incoming parameters in Velocity Template ?

Hi, dear all:
    I'm a newbie for Velocity. Currently I'm writing a Velocity Taglib for JSP to replace <jsp:include>.
example:

<macro:velo vm='DatePicker.vm'>
    <macro:param name="highlight" value="2004-5-13"/>
</macro:velo>

the <macro:param> actually is :
    context.put(name,value) 
before template merge.

New I havea problem , how can I iterate all incoming parameters in vm file?

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>

Thanks in advance!
Xiaogang Cao
from China.

Re: How to iterator all incoming parameters in Velocity Template ?

Posted by Geir Magnusson Jr <ge...@4quarters.com>.
On May 12, 2004, at 12:11 AM, Xiaogang Cao wrote:

> Hi, dear all:
>     I'm a newbie for Velocity. Currently I'm writing a Velocity Taglib 
> for JSP to replace <jsp:include>.
> example:
>
> <macro:velo vm='DatePicker.vm'>
>     <macro:param name="highlight" value="2004-5-13"/>
> </macro:velo>
>
> the <macro:param> actually is :
>     context.put(name,value)
> before template merge.
>
> 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

>
> Thanks in advance!
> Xiaogang Cao
> from China.
>
-- 
Geir Magnusson Jr                                   203-247-1713(m)
geir@4quarters.com


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


Re: Frames with Velocity

Posted by Simon Christian <si...@stoutstick.com>.
Sure you can use frames with Velocity, but only in the sense you can use 
them with any other static or dynamic page. Remember, Velocity is only 
server-side (in a web application) and frames are only client-side.

- simon


jules djilo wrote:

> Hallo
> I want to know how to use Frame with velocity,
> if it's posible to include frame.
> Tanks
> 
> 
> 
> 
> Jules Djilo
> F.-W.-von-Steuben Str 90 / B12
> 60488 Frankfurt am Main
> tel +49 1742425046
> 
> 
> ---------------------------------------------------------------------
> 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


Frames with Velocity

Posted by jules djilo <dj...@inm.de>.
Hallo
I want to know how to use Frame with velocity,
if it's posible to include frame.
Tanks




Jules Djilo
F.-W.-von-Steuben Str 90 / B12
60488 Frankfurt am Main
tel +49 1742425046


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