You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by "G.L. Grobe" <ga...@grobe.net> on 2002/05/26 00:47:20 UTC

passing in a param on method OR 2 iters in foreach

While trying to figure out a way to loop through two Vectors in a single #foreach statement ... I found something that might help if I can figure the following ... Is it possible to return an element from a Vector by passing in the index as shown below?

   #set ( $idx = 0 )
   #foreach ($span in $row.rowSpan)

      #if ($span == 0)
         <!-- do nothing -->
      #else
         <td style="width:50px" bgcolor="$row.rowState($idx)" rowspan="$span">$idx</td>
      #end

      #set ( $idx = $idx + 1 )
   #end

Any help much appreciated.

Re: passing in a param on method OR 2 iters in foreach

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 5/25/02 6:47 PM, "G.L. Grobe" <ga...@grobe.net> wrote:

> While trying to figure out a way to loop through two Vectors in a single
> #foreach statement ... I found something that might help if I can figure the
> following ... Is it possible to return an element from a Vector by passing in
> the index as shown below?
> 
>  #set ( $idx = 0 )
>  #foreach ($span in $row.rowSpan)
> 
>     #if ($span == 0)
>        <!-- do nothing -->
>     #else
>        <td style="width:50px" bgcolor="$row.rowState($idx)"
> rowspan="$span">$idx</td>


If $foo is truly a java.util.Vector, then $foo.elementAt($idx) will return
what I think you are asking for...


geir



>     #end
> 
>     #set ( $idx = $idx + 1 )
>  #end
> 
> Any help much appreciated.
> 

-- 
Geir Magnusson Jr.
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>