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

Using logic:iterate

 
Perindevi Peramur
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
There are a list of reports and each of the reports have been emailed to
people. For example : report 1 might have been emailed to 3 people ;
report 2 might have been emailed to 2 people etc. So, in a jsp page, I
need to display the list of report names. Under each of the report
names, I need to display the string "recipient(x)" where x is the
number of people the report has been mailed to. So, under report 1, 3
strings should be displayed "recipient 1, recipient 2, recipient 3" ;
under report 2, two strings should be displayed "recipient 1, recipient
2 " etc.
How will I accomplish the above using logic:iterate?

I know to display the report names one below the other. I need to put the report names in a list(collection) and put it in session. I can then use

<logic:iterate name="reports" property="reportNames"> ..</logic:iterate>

Similarly, I need to display the recipients using logic:iterate tag. For
this, I can put the number of recipients in a list. The ith elment of
the list will correspond to the ith report. But how should I display in
the Jsp ? How can I pass i into logic:iterate corresponding to the
recipient number .How to handle the <logic:iterate> inside <logic:iterate> ?

Any help is appreciated.


Thank you, Suman.

[ December 24, 2005: Message edited by: Suman Seshadri ]

[ December 24, 2005: Message edited by: Suman Seshadri ]
[ December 24, 2005: Message edited by: Suman Seshadri ]
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I strongly recommend using c:forEach (JSTL) instead of logic:iterate. Not only is it easier to use, it allows you to reference the index (aka the count) of the current iteration.

This site explains how to use it.
 
Perindevi Peramur
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Marc,
Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic