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