Wednesday, January 27, 2010

DisplayTag feature to expose row numbers

I was working on Spring MVC and DisplayTag to structure the table. I had a list of objects and needed to refer the index of an item because I had to use <spring:bind>

I discovered a cool DisplayTag feature that exposes the row number of an item. Here is an example:

<display:table name="ticketList" id="ticket"> 
<display:column title="Row Number">
${ticket_rowNum}
</display:column>
</display:table>



You are basically appending "_rowNum" to the variable to get the row number.