You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Shamdasani Nimmi-ANS004 <AN...@motorola.com> on 2001/02/28 22:22:40 UTC
PLEASE HELP: How would I use the iterate tag here?
Hi,
Could someone help me with replacing the JSP code below with iterate tag <logic:iterate> ? I have tried various permutations of <logic:iterate> but have been unsuccessful.
---------------------------------------------------------------------------
<jsp:useBean id="user" scope="session" type="com.motorola.mms.msqc.beans.UserBean"/>
</TABLE>
<%
Hashtable hashTable = (Hashtable) user.getSuppliers();
for (Enumeration e = hashTable.elements(); e.hasMoreElements(); )
{
SupplierBean supplier = (SupplierBean) e.nextElement();
%>
<TR>
<TD ><FONT face = "Arial">supplier.getCode() %></FONT></TD>
<TD><FONT face = "Arial"><%= supplier.getName() %></FONT></TD></FONT></TD>
<TD><FONT face = "Arial"><%= supplier.getCountryName() %></FONT></TD>
</TR>
<% } %>
</TABLE>
---------------------------------------------------------------------------
I can really use some help. Thanks in advance
-Nimmi
RE: PLEASE HELP: How would I use the iterate tag here?
Posted by Wes Hodges <wh...@fabgear.com>.
> Could someone help me with replacing the JSP code below with
> iterate tag <logic:iterate> ? I have tried various permutations
> of <logic:iterate> but have been unsuccessful.
>
> ------------------------------------------------------------------
> ---------
> <jsp:useBean id="user" scope="session"
> type="com.motorola.mms.msqc.beans.UserBean"/>
>
> </TABLE>
> <%
> Hashtable hashTable = (Hashtable) user.getSuppliers();
> for (Enumeration e = hashTable.elements(); e.hasMoreElements(); )
> {
> SupplierBean supplier = (SupplierBean) e.nextElement();
> %>
> <TR>
> <TD ><FONT face = "Arial">supplier.getCode() %></FONT></TD>
> <TD><FONT face = "Arial"><%= supplier.getName() %></FONT></TD></FONT></TD>
> <TD><FONT face = "Arial"><%= supplier.getCountryName() %></FONT></TD>
> </TR>
>
> <% } %>
> </TABLE>
<table>
<logic:iterate id="supplier" name="user" property="suppliers"
type="com.full.packagename.for.SupplierBean">
<tr><td><font face="Arial"><bean:write name="supplier"
property="code"/></td></tr>
<tr><td><font face="Arial"><bean:write name="supplier"
property="name"/></td></tr>
<tr><td><font face="Arial"><bean:write name="supplier"
property="countryName"/></td></tr>
</tr>
</logic:iterate>
</table>
Be sure to fix the package name in the type attr in logic:iterate.
This also assumes that there is an object in the session scope called user.
Wes