velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Romianowski" <megap...@gmx.de>
Subject RE: variable display problem
Date Mon, 14 Oct 2002 09:36:28 GMT
Perhaps you might want to put the Objects as a Map into the context.

Map map = new HashMap();
for (i = 0, i < something.length(), i++)
{
   ...
   map.put (""+i, aufdat);
   ...
}

context.put("aufdat", map);

And in the VM:

#foreach ($thing in $something)
    #set ($index = $index + 1)
    $aufdat.get($i)
#end

As I see, you can use a List, too, of course... depends on what your are
doing further :)

Peter


> -----Original Message-----
> From: Foth, Oliver [mailto:Oliver.Foth@gedas.de] 
> Sent: Monday, October 14, 2002 9:36 AM
> To: 'velocity-user@jakarta.apache.org'
> Subject: variable display problem
> 
> 
> Hi everybody,
> 
> I have the following problem, or better: challenge ;-)
> In a java file I've created some variables within an for loop:
> 
> for (i = 0, i < something.length(), i++)
> {
>    ...
>    context.put("aufdat_"+i, aufdat);
>    ...
> }
> 
> I can use them in the vm file and they are displayed 
> correctly. But instead of using them like:
> 
> $aufdat_1<BR/>
> $aufdat_2<BR/>
> ...
> 
> I need to use them in another loop:
> 
> #set ($index = 0)
> #foreach ($thing in $something)
>    #set ($index = $index + 1)
>    $aufdat_$index
> #end
> 
> How can I have "$aufdat_$index" displayed correctly?
> 
> 
> 		Gruß,
> 
> 		Oliver Foth
> > 	----------------------------------------------------
> > 	gedas deutschland GmbH
> > 	Teilelogistik
> > 	Johann-Siegmund-Schuckert-Str. 2a
> > 	D-34225 Baunatal
> > 	Telefon/phone	+49-561-49995-34
> > 	Telefax/telefax	+49-561-49995-52
> > 	Mailto: Oliver.Foth@gedas.de
> > 	http://www.gedas.com <http://www.gedas.com> 
> > 	----------------------------------------------------
> > 
> > 
> 


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


Mime
View raw message