• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

alternate rows in one color

 
Rahesh Kumar
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI

I am new to struts,can anyone help me put in displaying alternate rows in one different colors,the values as such are hardcoded.

Thanks

Rahesh
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have a dynamic number of rows that uses an iteration?
If so, run a test if the index (or the count) of the iteration is even or odd.
If even, make it the first color.
If odd, make it the second color.
 
Danilo Gurovich
author
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can also implement this functionality using struts-layout tags from the struts-layout home
 
George Franciscus
author
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Danilo loves those layout tags so much he wrote an entire chapter on them! In Struts Recipes we have a recipe on how to extend the Iterate tag to allow you to alternate any number of colors.

You can find out how to do it by downloading the sample chapter from
http://www.manning-source.com/books/franciscus/franciscus_chp2.pdf

It recipe 2.8 on p 80. Remember, Struts tags are meant to be extended. You can extend any tag in the library to do whatever you need them to do. This recipes shows you how to do that step-by-step.
 
Liz Brown
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have some columns in table (I iterate for these columns) which must be in another color. How to go about this?
example: out of 5 columns i have 2 columns with different color
 
Jason Menard
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Liz Brown:
I have some columns in table (I iterate for these columns) which must be in another color. How to go about this?
example: out of 5 columns i have 2 columns with different color


Did you read the the sample of chapter two of the book Struts Recipes that the author of that book mentioned above? As he said, recipe 2.8 on p80 of the book (which is p42 of the pdf) gives you about as good an explanation as you're likely to find. I suggest taking the author's advice and having a look at this.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic