raghu tadi <[EMAIL PROTECTED]> wrote:
> How do i get the Position value of a particular element in say a
> Vector when i use the iterate tag.Sample snippet would be like,
> <pre>
> Vector v has some String elements..
> for(int i =0 ; i < v.size(); i++)
> {
>    out.println(v.elementAt(i));
> }
> </pre>
> Question is: How do i get the i-th element from Vector V when i use
> the Iterate Tag..

As Jean-Noel said, if you really want to get a particular element, you
don't want to use iterate. But if what you are actually looking for is
how to get the index of the current element inside an iterate block, I
think you need to manage that separately. It's not ideal, but here's
what I do to produce a table with alternately shaded rows:

   <% int rowNumber = 0; %>
   <logic:iterate id="ddItem" name="dropdownItems">
     <% if( ( ++rowNumber % 2 ) == 1 ) { %>
     <tr class="listViewOdd">
     <% } else { %>
     <tr class="listViewEven">
     <% } %>
       <td>...</td>
       <td>...</td>
       <td>...</td>
     </tr>
   </logic:iterate>

It would be nice if interate also made an index available, but you can
do something like that as a work-around for now (unless someone has a
better suggestion).

--
Michael Hackett
Developer, Pictorius Inc.

Reply via email to