You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Apache Wiki <wi...@apache.org> on 2005/07/14 17:35:23 UTC
[Struts Wiki] Update of "Comparison using nested tag vs JSTL for nested
objects on form" by RickReumann
Dear Wiki user,
You have subscribed to a wiki page or wiki category on "Struts Wiki" for change notification.
The following page has been changed by RickReumann:
http://wiki.apache.org/struts/Comparison_using_nested_tag_vs_JSTL_for_nested_objects_on_form
New page:
=== Comparison using nested tag vs JSTL for nested objects on form ===
Many think that you are required to display nested data using the Nested tag. I agree the Nested tag is the cleaner solution, but just so you are aware you can do this with JSTL as well. (Below assumes JSP2.0)
companyForm has a List of divisions and for each division in the list there is a list of department objects and we will display the 'name' of each department.
''JSTL Solution''
{{{
<c:forEach items="${companyForm.divisions}" var="division" varStatus="divstatus">
Division: <html:text property="divisions[${divstatus.index}].name" value="${division.name}" /><br>
<c:forEach items="${division.departments}" var="department" varStatus="depstatus">
--- Department: <html:text property="divisions[${divstatus.index}].departments[${depstatus.index}].name" value="${department.name}" /><br>
</c:forEach>
</c:forEach>
}}}
''Nested Tag Solution''
{{{
<nested:root name="companyForm">
<nested:iterate property="divisions">
Division: <nested:text property="name" /><br>
<nested:iterate property="departments">
--- Department: <nested:text property="name" /><br>
</nested:iterate>
</nested:iterate>
</nested:root>
}}}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org