Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts 2 Iterating in ArrayList containing object Array

 
Divy Prakash
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • 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
 
Ankit Garg
Sheriff
Posts: 9528
32
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • 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
 
nitin jha
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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: 9528
32
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • 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...
 
Nitin Surana
Ranch Hand
Posts: 129
Java Netbeans IDE Windows
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic