• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just nest <logic:iterate> tags. Example:
 
Jenny Giovianni
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Merrill !, super thanks for your help, I tried it and it works now !

Thanks again,
J
 
You get good luck from rubbing the belly of a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic