This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

nested iterate-help

 
lee anthony
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
friends can any body tell me how do i iterate my category table with id, name,description fields
simultaneously iterate the inner table idea iterate with with catid, name,description fields
view should be with respect to categories id
that is ideas table should be display for each catid it should
id of category = catid of idea
i was trying to do some rnd but it is not working to my expectation

<logic:iterate id="category" name="categories">
<tr>
<td style="vertical-align: top;" bgcolor="#CBDAE5">
<bean:write name="category" property="id"/>
</td>
<td style="vertical-align: top;" bgcolor="#CBDAE5">
<bean:write name="category" property="name"/>
</td>
<td style="vertical-align: top;" bgcolor="#CBDAE5">
<bean:write name="category" property="description"/>
</td>
<td style="vertical-align: top;" bgcolor="#CBDAE5">
<html:link page="/Welcome.do">
<bean:message key="category.linkedit"/>
</html:link>
<a href="DeleteCategoryAction.do?action=delete&id=<bean:write name='category' property='id'/>"><bean:message key="category.linkdelete"/></a>
</td>
</tr>
<%-- Just rnd remove it later --%>
<logic:iterate id="idea" name="ideas" >
<tr>
<td style="vertical-align: top;" bgcolor="#CBDAE5">
<bean:write name="idea" property="id"/>
</td>
<td style="vertical-align: top;" bgcolor="#CBDAE5">
<bean:write name="idea" property="name"/>
</td>
<td style="vertical-align: top;" bgcolor="#CBDAE5">
<bean:write name="idea" property="description"/>
</td>
<td style="vertical-align: top;" bgcolor="#CBDAE5">
<html:link page="/Welcome.do">
<bean:message key="category.linkedit"/>
</html:link>
<a href="DeleteCategoryAction.do?action=delete&id=<bean:write name='category' property='id'/>">idealink</a>
</td>
</tr>
</logic:iterate>
 
Oliver Moore
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Lee...
Something like this perhaps? Will need some tweaking though...
<% String catCatId; %>
<logic:iterate id="category" name="categories">
<% catCatId = category.getId(); %>
Place rest for <bean:write > and HTML here for category
<logic:iterate id="idea" name="ideas" >
<% if (catCatID.equals(idea.getCatId())) { %>
Place rest for <bean:write > and HTML here for idea
<% } %>
</logic:literate>
</logic:literate>
You might be able to simplfy this futher with <logic:equal> tags...
Hope this is of some help (and correct :S)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic