each list item is attached to the tr tag. Therefore the OddEvenItem solution just works. Did you try it?
Martijn On Mon, Mar 29, 2010 at 9:24 AM, Arnaud Garcia <arn...@imagemed-87.com> wrote: > Hi, > > Defenitively it is more elegant to use the "OddEvenItem" object instead of > using my boolean... but it doesn't change my problem... > Changing the class of the items can be done easily (see my code, or you can > use OddEventItem etc..) But the problem is to change the class at the upper > level in the <tr> ? > > I am certainely not clear, so I can reformulate like this: how can you > create a table where lines are blue then white and so on when you iterate > over a ListView... > > thanks for help, > > Arnaud > > > 2010/3/28 Mauro Ciancio <maurocian...@gmail.com> > >> Take a look at: >> >> ListItem#newItem(final int index) >> >> and: >> >> org.apache.wicket.markup.repeater.OddEvenItem. >> >> Cheers. >> >> On Sun, Mar 28, 2010 at 11:40 AM, Arnaud Garcia <arn...@imagemed-87.com> >> wrote: >> > Hello, >> > >> > Using a ListView on a <tr> html markup, I would like to alternate the >> > background color of each "new" tr when the list iterate... >> > >> > I just find how to do this on the label inside the td... not on the <tr> >> > level..., so just the background color of the title is changed and not >> the >> > full line ! >> > >> > here is an example of my code.... >> > >> > html: >> > -------- >> > >> > <table> >> > <tr wicket:id="cdList"> >> > <td><span wicket:id="title"/></td> >> > </tr> >> > </table> >> > >> > >> > java: >> > ------ >> > ListView<CD> aList = new ListView<CD>("cdList",CDList) { >> > >> > private boolean alternateLine = true; // to switch css class >> > attribute at each new item... >> > >> > @Override >> > protected void populateItem(ListItem<CD> item) { >> > >> > Label title = new Label("title", new >> > PropertyModel<String>(item.getModelObject(), "title")); >> > >> > if (alternateLine) { >> > title.add(new SimpleAttributeModifier("class", "line1")); >> > // change the color ! >> > } else { >> > title.add(new SimpleAttributeModifier("class", "line2")); >> > } >> > alternateLine = !alternateLine; >> > >> > item.add(title) >> > } >> > } >> > >> > >> > thanks, >> > >> > Arnaud >> > >> >> >> >> -- >> Mauro Ciancio <maurociancio at gmail dot com> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org >> For additional commands, e-mail: users-h...@wicket.apache.org >> >> > -- Become a Wicket expert, learn from the best: http://wicketinaction.com Apache Wicket 1.4 increases type safety for web applications Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.4.4 --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org