Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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

foreach looping and counting

 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello cowboys,

I have a problem with creating dinamic table where every second row must has same colour, with jstl ofcourse;

so I have



class="red_row" is defined in css.

Can it be done somehow with pure jstl, with no scripting code?

Regardes,
Marko
 
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes.

Do you have a copy of the JSTL Specification handy? If not, you should.

When you get it, look up the varStatus attribute to <c:forEach>.

You will be pleased.
 
Marko Debac
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bear,

but varStatus is a String, I canot use him like "i", i.e. I canot do mod operation on him, so I cant get it, I have download jstl spec, bat its very poor explanation, with no examples

help
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Marko Debac:
Hi Bear,

but varStatus is a String, I canot use him like "i", i.e. I canot do mod operation on him, so I cant get it, I have download jstl spec, bat its very poor explanation, with no examples

help



From the JSTL Spec:


Chapter 6 Iterator Actions 39
6.1.3 Iteration Status
<c:forEach> also exposes information relative to the iteration taking place. The example below creates an HTML table with the first column containing
the position of the item in the collection, and the second containing the name of the product.

See Chapter 16 �Java APIs" for details on the LoopTagStatus interface exposed by the varStatus attribute.

 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
varStatus is an object with properties like count and index.
 
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
Maybe we have different spec. Mine is very clear

varStatus
Name of the exported scoped variable for the status of the iteration. Object exported is of type
javax.servlet.jsp.jstl.core.LoopTagStatus. This scoped variable has nested visibility.


Now if you look at the JSTL API, you'll find more about LoopTagStatus:
http://java.sun.com/products/jsp/jstl/1.1/docs/api/index.html
 
Marko Debac
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you guys a lot!

Marko
 
Now I am super curious what sports would be like if we allowed drugs and tiny ads.
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