I'm using a listview to output an ordered list. I would like to add a class to my li programatically. I don't see a way to do that using the ListView
simple template:
Code Block | ||||
---|---|---|---|---|
| ||||
<ol> <!-- want to add a class="foo" to this li! --> <li wicket:id="item">text goes here</li> </ol> |
code:
Code Block |
---|
populateItem(Item item) { item.add(new SimpleAttributeModifier("class", "foo")); } |
This will add a css class and replace any existing value. if you want to append the css incase someother class was added in the view, use this:
Code Block |
---|
populateItem(Item item) { item.add(new AttributeAppender("class", new Model("foo"), " ")); } |
This question was answered on the wicket-user mailing list on 10.18.2006