Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Iterate Tag

 
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
i have a problem with iterate tag
i have a collection of Product bean and i want to use withthe iterate tag. The tag iterate for 16 times whihc is good but it doesn't display values here is the code
<html>
<% HttpSession ses = request.getSession(true);
LogHelper mLogger = (LogHelper)ses.getAttribute("CRSLOGGER") ;
if (mLogger==null){
}else{
mLogger.debug("At least it came till here");
}
DBProxy dbProxy = new DBProxy();
mLogger.debug("Initialized DBProxy");
HashMap productHM = dbProxy.getProducts();
mLogger.debug("After getting products");
request.setAttribute("RR",productHM.values());
%>

Product Information Page Items Found <%=productHM.size()%>
<table>
<logic:iterate id="product" name="RR" scope="request" type="com.nilgiri.crs.customerResearch.Model.Product">
<tr>
<td>productID = <bean:write name="product" property="productID" /> </td>
<td>productName = <bean:write name="product" property="productName" /> </td>
<td>price = <bean:write name="product" property="price" /> </td>
<td>test</td>
</tr>
</logic:iterate>
</table>
The product class has just three porperties
if i use the conventional style like iterating thru the hash map it workd
any help will be appreiacted
 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Rashid,
Do you remember to add the following lines ?
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>

[ February 13, 2004: Message edited by: Jacky Chow ]
 
Ranch Hand
Posts: 452
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If u have added the code given by Jacky, and you are still facing problem add the following line before logic:iterate tag
<bean efine id="product" name="a" property="b"/>
a = Action Form name as defined in strutsconfig.xml
b = HashMap or ArrayList of the ActionForm u want to iterate
 
Rashid Darvesh
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did define the tag library and as for using the bean define tag my product class is just an ordinary bean and it is not action form bean so i cant use it as suggested by Prakash Dwivedi. still no luck as of now
reply
    Bookmark Topic Watch Topic
  • New Topic