| This example tag creates an HTML table with multiple rows. It takes
a Collection from the session (attribute key is
currentCollection) and iterates through the elements.
The elements are stored in the request (attribute key is currentObject).
The body of the tag will be evaluated multiple times, and if it's not empty,
an HTML row will be created.
A Struts bean:write or JSTLc:outtag can be used to write the
elements from the Collection as a string to the page.
If you store a List with one entry Entry1 in the session
and specify the following JSP code (enumtag is our tag)
<mytags:enumtag label="myLabel">
<bean:write scope="request" name="currentObject"/>
</mytags:enumtag>
then the html output will be
<table>
<tr>
<td>
myLabel
</td>
<td>
Entry1
</td>
</tr>
</table>
Note: The bean:write tag is the common Struts tag.
Check out
TableEnumTagTest to see how to write a test for
this tag.
|