Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Pras Tiwari
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
 
Merrill Higginson
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.
 
Dhulipalla
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic