Win a copy of TDD for a Shopping Website LiveProject this week in the Testing 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

JSTL iteration of a list with numbering

 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am iterating over an ArrayList of objects. For each entry I createe a table row encapsulated within a form. In addition to iterate through the ArrayList I need to insert a number within the iteration so that each form element gets it unique id.

If it was scriptlet I would have no problem, but I am using JSTL <c:forEach>



How can I get the value for each iteration and pass it into formID#. Somehow I need to access the iteration number, like the i in for(int i = 0; i<list.size();i++)

I am using JSTL 1.1 and JSP 2.0 with Servlet-API 2.5
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use varStatus attribute of the forEach tag :


varStatus is of type LoopTagStatus. Check the API for the details of this class.
[ August 22, 2007: Message edited by: Christophe Verre ]
 
Sverre Moe
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Christophe Verre:
Use varStatus attribute of the forEach tag :


varStatus is of type LoopTagStatus. Check the API for the details of this class.

[ August 22, 2007: Message edited by: Christophe Verre ]



Thanks, just what I was looking for
 
Won't you please? Please won't you be my neighbor? - Fred Rogers. Tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic