Solved

How to use <logic:iterate> strut tag to loop arrayList that holds other arrayList

Posted on 2007-04-05
5
3,270 Views
Last Modified: 2013-11-24
Hi, I set in request “arrayListParent” that holds a couple of “arrayListChildren.  I know how to loop through one arraylist using <logic:iterate>, but in this case, I have an arraylist holding other arrayList.  I have pasted my current jsp code on the bottom that uses scripting to display the arraylist and it’s children, that works fine.  But can anyone provide me an example to do that using controls like code directly below here?
Thanks so much for your help,
noijet
 ********* Version with jsp tag controls *******
<logic:iterate id="courses" name="arrayListParent" scope="request"
        type="java.util.ArrayList">    
            ……..//Have no idea how to get arrayListChildren            
</logic:iterate>    
************** Current version in JSP*********
    <%    
    ArrayList arrayListParent = (ArrayList)request.getAttribute( “arrayListParent”);
    ArrayList attendees = new ArrayList();
    Iterator iterator = arrayListParent.iterator();
    Attendee attendee = new Attendee();        
      for (int i = 0; iterator.hasNext();i++) {
          attendees = (ArrayList)iterator.next();
          Iterator iterator2 = attendees.iterator();
          for(int j = 0; iterator2.hasNext();i++) {
              attendee = (Attendee)iterator2.next();              
              %><%= attendee.getLastName()%>,<%=attendee.getFirstName()%>              
              <%              
          }
    }    
    %>

0
Comment
Question by:noijet
  • 2
  • 2
5 Comments
 
LVL 10

Assisted Solution

by:Jaax
Jaax earned 30 total points
Comment Utility
0
 

Author Comment

by:noijet
Comment Utility
Hi Jaax, thanks for your reply:
  Reading that message: I can do:
<logic:iterate id="parent" name="arrayListParent" scope="request"
        type="java.util.ArrayList">    
           <logic:iterate id="child" name="arrayListChildren"   type="java.util.ArrayList">
                  <bean:define name="child" property="firstname"/> ,  
                  <bean:define name="child" property="firstname"/>  
          </logic:iterate>
</logic:iterate>    
***My question is "arrayListChildren" holds a list of objects of type Child that has properties firstname and lastname, the above code would work right?

Thanks,
noijet
0
 
LVL 11

Expert Comment

by:Manish
Comment Utility
Inside it, again use logic iterate tag.
0
 
LVL 11

Accepted Solution

by:
Manish earned 95 total points
Comment Utility
Can you try this..?
 <logic:iterate id="child" name="arrayListChildren"   type="com...Attendee">
0
 

Author Comment

by:noijet
Comment Utility
Hi all, I will try out suggestions and get back you you!

Thanks again,
noijet
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
tenRun challenge 28 81
Spring Controller - inheritance in request parameter 3 37
json example 39 110
groovy example issue 10 65
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now