I want to use the count from the JSTL forEach loop, but my code doesnt seem to work.
<c:forEach items="${loopableObject}" var="theObject" varStatus="theCount">
<div id="divIDNo${theCount}">
</div>
</c:forEach>
produces
<div id="divIDNojavax.servlet.jsp.jstl.core.LoopTagSupport$1Status@5570e2" >
you'd use any of these:
JSTL c:forEach varStatus properties
Property Getter Description
current getCurrent() The item (from the collection) for the current round of iteration.
index getIndex() The zero-based index for the current round of iteration.
count getCount() The one-based count for the current round of iteration
last isLast() Flag indicating whether the current round is the last pass through the iteration
begin getBegin() The value of the begin attribute
end getEnd() The value of the end attribute
step getStep() The value of the step attribute
Its really helped me to dynamically generate ids of
showDetailItem
for the below code.if you execute this line
<af:outputText value="#{ttfVs}"/>
prints the below:The variable set by varStatus is a LoopTagStatus object, not an int. Use:
To clarify:
${theCount.index}
starts counting at 0${theCount.count}
starts counting at 1You can try this. similar result