I see you are trying to add the class modifier to "item" which is ListItem
and thats not a HTML component.
In my case, I was adding it to the link or label. I think you may have to do
something like
item.add(new Label(...).add(new AttributeModifier("class", new
AbstractReadOnlyModel() ...
etc.
On Wed, Jun 24, 2009 at 7:28 AM, Azzeddine Daddah <[email protected]>wrote:
> Thanks Vasu for your replay.
>
> I've tried your suggestion, but didn't work. This is what I get in the
> Ajax debuger when I click a certain item:
> ...
> <li>
> <a id="topicLink31" href="#" onclick="var
>
> wcall=wicketAjaxGet('?wicket:interface=:0:container:categories:3:topics:3:topicLink::IBehaviorListener:0:-1',null,null,
> function() {return Wicket.$('topicLink31') !=
> null;}.bind(this));return !wcall;"><span>Yeeh</span></a>
> </li>
> ...
>
> Does someone else already got the same issue?
>
> Regards,
> Hbiloo
>
>
> On Wed, Jun 24, 2009 at 12:36 PM, Vasu Srinivasan<[email protected]>
> wrote:
> > Ive got a very similar thing working.
> >
> > I think you may have to return the "highlight" value dynamically. Try
> this
> > alternative:
> >
> > item.add(new AttributeModifier("class", true, new AbstractReadOnlyModel()
> {
> > @Override public Object getObject() {
> > return "highlight"
> > }
> > });
> >
> > On Tue, Jun 23, 2009 at 5:56 PM, Azzeddine Daddah <[email protected]
> >wrote:
> >
> >> Hi Wicket users,
> >>
> >> I've a ListView in a ListView. The 1st ListVeiw holds "categories".
> >> The 2nd ListView holds links (topics) which I want to be highlighted
> >> if the link (topic) is clicked. The problem is that the wrapped list
> >> (container) is getting refreshed, but the CSS class is not set for the
> >> corresponding list item.
> >> Below my code:
> >>
> >> TestPage.java
> >> ========================================
> >> import java.io.Serializable;
> >> import java.util.ArrayList;
> >> import java.util.Arrays;
> >> import java.util.List;
> >>
> >> import org.apache.wicket.AttributeModifier;
> >> import org.apache.wicket.ajax.AjaxRequestTarget;
> >> import org.apache.wicket.ajax.markup.html.AjaxLink;
> >> import org.apache.wicket.markup.html.WebMarkupContainer;
> >> import org.apache.wicket.markup.html.basic.Label;
> >> import org.apache.wicket.markup.html.list.ListItem;
> >> import org.apache.wicket.markup.html.list.ListView;
> >> import org.apache.wicket.model.Model;
> >> import org.wicketstuff.annotation.mount.MountPath;
> >>
> >> import com.hbiloo.receptino.web.page.template.PageWithoutSideBar;
> >>
> >> @MountPath(path = "test")
> >> public class TestPage extends PageWithoutSideBar {
> >>
> >> @SuppressWarnings("serial")
> >> public TestPage() {
> >> final WebMarkupContainer container = new
> >> WebMarkupContainer("container");
> >> container.setOutputMarkupId(true);
> >>
> >> container.add(new ListView<Category>("categories",
> >> buildCategories()) {
> >> @Override
> >> protected void populateItem(ListItem<Category>
> item)
> >> {
> >> Category category =
> item.getModelObject();
> >> item.add(new Label("category",
> >> category.getName()));
> >> item.add(new ListView<Topic>("topics",
> >> category.getTopics()) {
> >> @Override
> >> protected void populateItem(final
> >> ListItem<Topic> item) {
> >> Topic topic =
> >> item.getModelObject();
> >> AjaxLink<String>
> topicLink =
> >> (new AjaxLink<String>("topicLink") {
> >> @Override
> >> public void
> >> onClick(AjaxRequestTarget target) {
> >>
> >> target.addComponent(container);
> >>
> item.add(new
> >> AttributeModifier("class", true, new
> >> Model<String>("highlight")));
> >> }
> >> });
> >> topicLink.add(new
> >> Label("topic", topic.getName()));
> >> item.add(topicLink);
> >> }
> >> });
> >> }
> >> });
> >> add(container);
> >> }
> >>
> >> @SuppressWarnings("serial")
> >> private class Category implements Serializable {
> >> private String name;
> >> private List<Topic> topics;
> >>
> >> public Category(String name, List<Topic> topics) {
> >> this.name = name;
> >> this.topics = topics;
> >> }
> >>
> >> public String getName() {
> >> return name;
> >> }
> >>
> >> public List<Topic> getTopics() {
> >> return topics;
> >> }
> >> }
> >>
> >> @SuppressWarnings("serial")
> >> private class Topic implements Serializable {
> >> private String name;
> >>
> >> public Topic(String name) {
> >> this.name = name;
> >> }
> >>
> >> public String getName() {
> >> return name;
> >> }
> >> }
> >>
> >> private List<Category> buildCategories() {
> >> List<Category> categories = new ArrayList<Category>();
> >> categories.add(new Category("Movies", Arrays.asList(new
> >> Topic("Mamma"),
> >> new Topic("USA"), new Topic("NL"))));
> >> categories.add(new Category("Articles", Arrays.asList(
> >> new Topic("Test"), new
> >> Topic("Nederland"))));
> >> categories.add(new Category("Images", Arrays.asList(new
> >> Topic("Mag"),
> >> new Topic("Spullen"), new Topic("Mamma
> >> mia"))));
> >> categories.add(new Category("Links", Arrays.asList(new
> >> Topic("Ana"),
> >> new Topic("Smiti"), new Topic("Hbiloo"),
> new
> >> Topic("Yeeh"))));
> >> return categories;
> >> }
> >> }
> >>
> >> TestPage.html
> >> ========================================
> >> <html xmlns:wicket>
> >> <wicket:extend>
> >> <ul class="menu" wicket:id="container">
> >> <li class="r" wicket:id="categories"><span class="category"
> >> wicket:id="category">Category A: </span>
> >> <ul>
> >> <li wicket:id="topics"><a wicket:id="topicLink"><span
> >> wicket:id="topic">Link</span></a></li>
> >> </ul>
> >> </li>
> >> </ul>
> >> </wicket:extend>
> >> </html>
> >>
> >> Kind regards,
> >>
> >> Hbiloo
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [email protected]
> >> For additional commands, e-mail: [email protected]
> >>
> >>
> >
> >
> > --
> > Regards,
> > Vasu Srinivasan
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
--
Regards,
Vasu Srinivasan