Use a RenderTool (see VelocityTools) or put the context in the context
and use $context.get('cur_${c}')On Sun, Feb 21, 2010 at 3:10 PM, danny van elsen <[email protected]> wrote: > hello all, > > ok, I've managed to write a Java program that will treat input data in a > generic way. > > for example, the data for the EUR currency > stringlist cur_EUR year value1 value2 > stringlist cur_EUR 2009 EUR-2009-1 EUR-2009-2 > stringlist cur_EUR 2010 EUR-2010-1 EUR-2010-2 > > ( > the program will do > context.put("cur_EUR", my_object_that_contains_the_three_data_lines) > ) > > will be interpreted by > #foreach( $res in $cur_EUR ) > #if ($velocityCount > 0) > <td> $res.get_string(0) : $res.get_string(1) : > $res.getColumn("year") </td> > #end > #end > > to output the corresponding data in cur_EUR > > so far so good... > > but what if I want to carry this to one level higher, and do not know in > advance how many currencies will have to be treated? > > with the input data > stringrow currencies EUR USD JPY > stringlist cur_EUR year value1 value2 > stringlist cur_EUR 2009 EUR-2009-1 EUR-2009-2 > stringlist cur_EUR 2010 EUR-2010-1 EUR-2010-2 > stringlist cur_USD year value1 value2 > stringlist cur_USD 2009 USD-2009-1 USD-2009-2 > stringlist cur_USD 2010 USD-2010-1 USD-2010-2 > stringlist cur_USD 2011 USD-2011-1 USD-2011-2 > > I thought I could do something like > #foreach( $c in $currencies ) <-- this will yield [EUR, USD, > JPY] > #foreach( $y in cur_${c} ) <-- this would have to give > [cur_EUR, cur_USD, cur_JPY] > $y.get_string(0) > #end > #end > > but this will not work? > > is there any way that the container in the #foreach statement can be the > concatenation of a literal and the result of a previous Velocity > variable interpretation? > > > On Mon, 2010-02-15 at 15:20 -0700, ChadDavis wrote: > >> I have had no trouble working with maps and collections of all kinds. >> > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
