GeeCON Prague 2014*
The moose likes Struts and the fly likes Using logic:iterate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Using logic:iterate" Watch "Using logic:iterate" New topic
Author

Using logic:iterate

Perindevi Peramur
Greenhorn

Joined: Dec 24, 2005
Posts: 10
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

Joined: Feb 05, 2003
Posts: 4727

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.


A good workman is known by his tools.
Perindevi Peramur
Greenhorn

Joined: Dec 24, 2005
Posts: 10
Hi Marc,
Thanks.
 
GeeCON Prague 2014
 
subject: Using logic:iterate