• 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:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Struts 2 Iterating in ArrayList containing object Array

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I know that we can iterate through an arrylist using iterator tag in Struts 2 .

But my Array list contains multiple object arrays.

So how can i itreate through those object arrays present inside the ArrayList?

I need to diplsy it on JSP page using Struts 2.

Thanks
DP
 
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This shouldn't be much of a sweat. You can iterate over the elements in the ArrayList and then iterate over the Object[] in each element. The smallest piece of code that can do this would look like this
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have ArrayList in request which contais bean object I am not able to Itrate this bean in jsp

What is the problem in this code???

ArrayList approverList = activateApproverDAO.getApproverRecord();
System.out.println("got List form PRM Database...");
Iterator itr = approverList.iterator();
while (itr.hasNext()) {
ActivateApproverBeanVO activateApproverBeanVO = (ActivateApproverBeanVO)itr.next();
System.out.println("User Id....."+ activateApproverBeanVO.getUserId());
System.out.println("Approver Type...."+activateApproverBeanVO.getApproverType());
System.out.println("Status....."+activateApproverBeanVO.getStatus());
}

request.setAttribute("listApprover", approverList);


**************************

<logic:iterate id="appId" name="listApprover" scope="request">
<bean:define id="approverRecord" name="appId"
type="com.techm.sdp.prm.vo.ActivateApproverBeanVO" />
<tr>
<logic:iterate id="approverDetail" name="approverRecord">
<td class="tdspace" align="left">
<bean:write name="approverDetail" property="userId" />
</td>
<td class="tdspace" align="left">
<bean:write name="approverDetail" property="approverType" />
</td>
<td class="tdspace" align="right">
<bean:write name="approverDetail" property="status" />
</td>
</logic:iterate>
</tr>
</logic:iterate>
 
Ankit Garg
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nitin, please start a new topic for your question. Click on to start a new topic. Also please UseCodeTags to wrap your code inside [code][/code] tags...
 
Ranch Hand
Posts: 129
Netbeans IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is a working example (Netbeans 6.9) project, which not only
iterates over a list of custom POJOs/Objects/Beans, but also re-creates the list of objects on form submission, so at the receiving action only the setter of that particular
list is required.
Simply resolve the references and get going.
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic