This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Child pages
  • How to programatically add css class to list item
Skip to end of metadata
Go to start of metadata

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:

<ol>
  <!-- want to add a class="foo" to this li! -->
  <li wicket:id="item">text goes here</li>
</ol>

code:

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:

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

  • No labels