Get Row Id From A Display Tag Table On A Jsp, Into A Struts 2 Action Class
I am using display tag to display data in a table on a JSP. Now I want to give two links for each row, one for editing & one for deleting the row. There are some posts on stack
Solution 1:
The current element of the list is available through the page context attribute "foobar" if the display:table
tag has the attribute uid="foobar"
(or id="foobar"
). See http://www.displaytag.org/1.2/displaytag/tagreference.html
Solution 2:
Display Tag uses Implicit Objects to store the row number. Here is an example from the Display Tag documentation:
<displaytableid="row"name="mylist"><display:columntitle="row number" ><c:outvalue="${row_rowNum}"/></display:column><display:columntitle="name" ><c:outvalue="${row.first_name}"/><c:outvalue="${row.last_name}"/></display:column></display:table>
So you can use EL to access the row number which is stored as an automatically created object. Its name is defined by your id
variable (in this case row
) with appended _rowNum
(in this case resulting in ${row_rowNum}
).
Be aware that the numbering starts at 1, not at 0.
Post a Comment for "Get Row Id From A Display Tag Table On A Jsp, Into A Struts 2 Action Class"