<c:forEach> supports a "varStatus" attribute. The value of that atrribute is a
String that names an instance of javax.servlet.jsp.jstl.core.LoopTagStatus. The
LoopTagStatus instance has nested visibility so that it's only available within
the enclosing <c:forEach> tag. LoopTagStatus exposes a number of properties,
but the one you're probably interested in is "index":

..
  <c:forEach var="bean" varStatus="status" items="${entry.value}">
    <%-- ${status.index} is the current index --%>
    ...
  </c:forEach>
..

Quoting Erik Weber <[EMAIL PROTECTED]>:

> How can I refer to the index of the current iteration with c:forEach 
> (analogous to the indexId attribute to logic:iterate)?
> 
> Thanks,
> Erik
> 
> 
> Kris Schneider wrote:
> 
> ><%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"; %>
> >
> ><c:forEach var="entry" items="${map}">
> >  <%-- ${entry.key} is the current key --%>
> >  <%-- ${entry.value} is the associated bean array --%>
> >  <c:forEach var="bean" items="${entry.value}">
> >    ...
> >  </c:forEach>
> ></c:forEach>
> >
> >Quoting Erik Weber <[EMAIL PROTECTED]>:
> >
> >  
> >
> >>I could use some Struts-EL/JSTL tag help, please.
> >>
> >>I have a Map with each entry having a String as the key and a bean array 
> >>as the value.
> >>
> >>I need two iterations, one nested inside the other.
> >>
> >>For the outer iteration, I want to iterate the keySet of the Map. I 
> >>don't know what the keys are going to be or how many there will be.
> >>
> >>Within that iteration, for each key in the keySet, I need to iterate 
> >>over the buckets of the array that is the value for that key.
> >>
> >>To make this more clear, let's say I will produce a table of tables, 
> >>somewhat like this:
> >>
> >><table>
> >>
> >>  <!-- start outer iteration here; iterate over the keySet of the Map -->
> >>
> >>  <!-- Map key #0 -->
> >>
> >>  <tr>
> >>
> >>    <td>
> >>
> >>      <table>
> >>
> >>        <!-- start inner iteration #1 here; iterate over the Object[] that
> is
> >>the value for key #1 in the Map -->
> >>
> >>        <!-- Object[bucket #0] -->
> >>
> >>        <tr>
> >>
> >>          <td><!-- Object[bucket #0].property A --></td>
> >>
> >>          <td><!-- Object[bucket #0].property B --></td>
> >>
> >>        </tr>
> >>
> >>        <!-- end Object[bucket #0] -->
> >>
> >>        <!-- Object[bucket #1] -->
> >>
> >>        <tr>
> >>
> >>          <td><!-- Object[bucket #1].property A --></td>
> >>
> >>          <td><!-- Object[bucket #1].property B --></td>
> >>
> >>        </tr>
> >>
> >>        <!-- end Object[bucket #1] -->
> >>
> >>      </table>
> >>
> >>    </td>
> >>
> >>  </tr>
> >>
> >>  <!-- end Map key #0 -->
> >>
> >>  <!-- Map key #1 -->
> >>
> >>  <tr>
> >>
> >>    <td>
> >>
> >>      <table>
> >>
> >>        <!-- start inner iteration #2 here; iterate over the Object[] that
> is
> >>the value for key #2 in the Map -->
> >>
> >>        <!-- Object[bucket #0] -->
> >>
> >>        <tr>
> >>
> >>          <td><!-- Object[bucket #0].property A --></td>
> >>
> >>          <td><!-- Object[bucket #0].property B --></td>
> >>
> >>        </tr>
> >>
> >>        <!-- end Object[bucket #0] -->
> >>
> >>        <!-- Object[bucket #1] -->
> >>
> >>        <tr>
> >>
> >>          <td><!-- Object[bucket #1].property A --></td>
> >>
> >>          <td><!-- Object[bucket #1].property B --></td>
> >>
> >>        </tr>
> >>
> >>        <!-- end Object[bucket #1] -->
> >>
> >>      </table>
> >>
> >>    </td>
> >>
> >>  </tr>
> >>
> >>  <!-- end Map key #1 -->
> >>
> >>  <!-- end outer iteration -->
> >>
> >></table>
> >>
> >>
> >>Could someone show me some skeleton JSTL or Struts-el code?
> >>
> >>I would appreciate it very much,
> >>Erik

-- 
Kris Schneider <mailto:[EMAIL PROTECTED]>
D.O.Tech       <http://www.dotech.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to