Win a copy of Svelte and Sapper in Action this week in the 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

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

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
J
Note: I removed all left/right angle brackets to post this question.
********* 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()%
%
}
}
%
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just nest <logic:iterate> tags. Example:
 
Jenny Giovianni
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Merrill !, super thanks for your help, I tried it and it works now !

Thanks again,
J
 
Space pants. Tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic