Reputation: 4807
I have display table like below
<display:table name="sample" id="sample" class="display-table" style="width:100%;">
</display:table>
Now I want to get index of loop like for first element 0 for second 1 and 2,3,4... go on. How it is possible with display table.
For just reference we can do like this in JSTL forEach loop with help of varStatus variable like below
<c:forEach items="${sample}" var="clm" varStatus="status">
${status.index}
</c:forEach>
So is this possible with display table?
Upvotes: 2
Views: 4670
Reputation: 3795
display table tag implicitly exposes row number named id_rowNum where id is specified in display table tag.
In your scenario:
<display:table name="sample" id="sample" class="display-table" style="width:100%;">
<display:column title="Row Number" >
<c:out value="${sample_rowNum - 1}"/>
</display:column>
...
</display:table>
Also make sure to include core tag as:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
You can find more information about implicit objects of display table tag here.
Upvotes: 4