This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

What is other way to iterate throgh collection instead of logic:iterate...?

 
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
In my application I want to display array of records into the html table having 5 columns. Out of five columns 3 columns are taking values from one collection (say partsdata[]) & other two columns are taking values from second collection(say orderdata[]). At any time both collections will have same size. How should I display records from both collection simultaneously into my table in JSP file?
Is there any other way to iterate through collections other than <logic:iterate...?
that is, like:- <bean:write name="orderForm" property="partsdata[0].partno"/> & so on...
Please reply.
Thank you.
Prash
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're on the right track. If you are sure the length of the arrays will always be the same, you can iterate over one array and use the same index for both arrays:

<logic:iterate id="part" name="orderForm" property="partsData" indexId="i">
<bean:write name="orderForm" property='<%=partsData["+i+"]".partno%>' />
<bean:write name="orderForm" property='<%=orderData["+i+"]".orderno%>' />
</logic:iterate>

The above code assumes you have indexed getters and setters for both partsData and orderData.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then your problem will be answered if you use an opensource tag called displaytag

http://displaytag.sourceforge.net/11/
 
Pras Tiwari
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I saw the link you provided to me http://displaytag.sourceforge.net
& also I downloaded displaytag1.1.jar from site. Now I copied thhis jar into my web-inf/lib directory of my web project. I am using STRUTS1.1 for my web development. What are the additional changes I need to do so as to work display tags for my web application. I tried by simply writeing following Taglib header into my JSP page:-
<%@ taglib uri="http://displaytag.sf.net"; prefix="display" %>

But when I am running my jsp page , it gives me error like:-
java.lang.NoClassDefFoundError: org/apache/commons/lang/UnhandledException
java.lang.Class.getDeclaredConstructors0(Native Method)
java.lang.Class.privateGetDeclaredConstructors(Class.java:2328)
java.lang.Class.getConstructor0(Class.java:2640)
java.lang.Class.newInstance0(Class.java:321)
java.lang.Class.newInstance(Class.java:303)

So how to solve it?

Please help me.
thank you.
Prash
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic