Re: Re: AttributeModifier not added to a ListView item via an AjaxLink
Martijn, I tried your solustion(s), but the CSS class of the topicLabel still not updated. public TestPage() { final WebMarkupContainer container = new WebMarkupContainer(container); container.setOutputMarkupId(true); container.add(new ListViewCategory(categories, buildCategories()) { @Override protected void populateItem(ListItemCategory item) { Category category = item.getModelObject(); item.add(new Label(category, category.getName() + : )); ListViewTopic topicListView; item.add(topicListView = new ListViewTopic(topics, category.getTopics()) { @Override protected void populateItem(final ListItemTopic item) { Topic topic= item.getModelObject(); final Label topicLabel = new Label(topic, topic.getName()); item.add(new AjaxLinkString(topicLink) { @Override public void onClick(AjaxRequestTarget target) { topicLabel.add(new AttributeModifier(class, true, new AbstractReadOnlyModelString() { @Override public String getObject() { return highlight; } })); target.addComponent(container); } }.add(topicLabel)); } }); topicListView.setReuseItems(true); } }); add(container); } div wicket:id=container ul class=menu li class=r wicket:id=categories span class=category wicket:id=categoryCategory A: /span ul li wicket:id=topics a wicket:id=topicLinkspan wicket:id=topicLink/span/a /li /ul /li /ul /div - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: AttributeModifier not added to a ListView item via an AjaxLink
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 waarhei...@gmail.comwrote: 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 ListViewCategory(categories, buildCategories()) { @Override protected void populateItem(ListItemCategory item) { Category category = item.getModelObject(); item.add(new Label(category, category.getName())); item.add(new ListViewTopic(topics, category.getTopics()) { @Override protected void populateItem(final ListItemTopic item) { Topic topic = item.getModelObject(); AjaxLinkString topicLink = (new AjaxLinkString(topicLink) { @Override public void onClick(AjaxRequestTarget target) { target.addComponent(container); item.add(new AttributeModifier(class, true, new ModelString(highlight))); } }); topicLink.add(new Label(topic, topic.getName())); item.add(topicLink); } }); } }); add(container); } @SuppressWarnings(serial) private class Category implements Serializable { private String name; private ListTopic topics; public Category(String name, ListTopic topics) { this.name = name; this.topics = topics; } public String getName() { return name; } public ListTopic 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 ListCategory buildCategories() { ListCategory categories = new ArrayListCategory(); 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
Re: AttributeModifier not added to a ListView item via an AjaxLink
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;spanYeeh/span/a /li ... Does someone else already got the same issue? Regards, Hbiloo On Wed, Jun 24, 2009 at 12:36 PM, Vasu Srinivasanvasy...@gmail.com 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 waarhei...@gmail.comwrote: 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 ListViewCategory(categories, buildCategories()) { �...@override protected void populateItem(ListItemCategory item) { Category category = item.getModelObject(); item.add(new Label(category, category.getName())); item.add(new ListViewTopic(topics, category.getTopics()) { �...@override protected void populateItem(final ListItemTopic item) { Topic topic = item.getModelObject(); AjaxLinkString topicLink = (new AjaxLinkString(topicLink) { �...@override public void onClick(AjaxRequestTarget target) { target.addComponent(container); item.add(new AttributeModifier(class, true, new ModelString(highlight))); } }); topicLink.add(new Label(topic, topic.getName())); item.add(topicLink); } }); } }); add(container); } �...@suppresswarnings(serial) private class Category implements Serializable { private String name; private ListTopic topics; public Category(String name, ListTopic topics) { this.name = name; this.topics = topics; } public String getName() { return name; } public ListTopic 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 ListCategory buildCategories() { ListCategory categories = new ArrayListCategory(); categories.add(new Category(Movies, Arrays.asList(new Topic(Mamma), new Topic(USA), new Topic(NL;
Re: AttributeModifier not added to a ListView item via an AjaxLink
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 waarhei...@gmail.comwrote: 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;spanYeeh/span/a /li ... Does someone else already got the same issue? Regards, Hbiloo On Wed, Jun 24, 2009 at 12:36 PM, Vasu Srinivasanvasy...@gmail.com 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 waarhei...@gmail.com 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 ListViewCategory(categories, buildCategories()) { @Override protected void populateItem(ListItemCategory item) { Category category = item.getModelObject(); item.add(new Label(category, category.getName())); item.add(new ListViewTopic(topics, category.getTopics()) { @Override protected void populateItem(final ListItemTopic item) { Topic topic = item.getModelObject(); AjaxLinkString topicLink = (new AjaxLinkString(topicLink) { @Override public void onClick(AjaxRequestTarget target) { target.addComponent(container); item.add(new AttributeModifier(class, true, new ModelString(highlight))); } }); topicLink.add(new Label(topic, topic.getName())); item.add(topicLink); } }); } }); add(container); } @SuppressWarnings(serial) private class Category implements Serializable { private String name; private ListTopic topics; public Category(String name, ListTopic topics) { this.name = name; this.topics = topics; } public String getName() { return name; } public ListTopic getTopics() { return topics; } } @SuppressWarnings(serial) private class Topic implements Serializable { private String name; public Topic(String name) {
Re: AttributeModifier not added to a ListView item via an AjaxLink
Thanks again Vasu, I've tried your solution but it does not work yet. Below my code: public TestPage() { final WebMarkupContainer container = new WebMarkupContainer(container); container.setOutputMarkupId(true); container.add(new ListViewCategory(categories, buildCategories()) { @Override protected void populateItem(ListItemCategory item) { Category category = item.getModelObject(); item.add(new Label(category, category.getName())); item.add(new ListViewTopic(topics, category.getTopics()) { @Override protected void populateItem(final ListItemTopic item) { final Topic topic = item.getModelObject(); final Label topicLabel = new Label(topic, topic.getName()); item.add(new AjaxLinkString(topicLink) { @Override public void onClick(AjaxRequestTarget target) { item.add(topicLabel).add(new AttributeModifier(class, true, new AbstractReadOnlyModelString() { @Override public String getObject() { return highlight; } })); target.addComponent(container); } }.add(topicLabel)); } }); } }); add(container); } Any other suggestions? Regards, Hbiloo On Wed, Jun 24, 2009 at 3:48 PM, Vasu Srinivasanvasy...@gmail.com wrote: 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 waarhei...@gmail.comwrote: 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;spanYeeh/span/a /li ... Does someone else already got the same issue? Regards, Hbiloo On Wed, Jun 24, 2009 at 12:36 PM, Vasu Srinivasanvasy...@gmail.com 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 waarhei...@gmail.com 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 ListViewCategory(categories, buildCategories()) { �...@override protected void populateItem(ListItemCategory item) { Category category = item.getModelObject(); item.add(new Label(category, category.getName())); item.add(new ListViewTopic(topics, category.getTopics()) { �...@override
Re: AttributeModifier not added to a ListView item via an AjaxLink
listview.setReuseItems(true) Martijn On Wed, Jun 24, 2009 at 5:03 PM, Azzeddine Daddahwaarhei...@gmail.com wrote: Thanks again Vasu, I've tried your solution but it does not work yet. Below my code: public TestPage() { final WebMarkupContainer container = new WebMarkupContainer(container); container.setOutputMarkupId(true); container.add(new ListViewCategory(categories, buildCategories()) { �...@override protected void populateItem(ListItemCategory item) { Category category = item.getModelObject(); item.add(new Label(category, category.getName())); item.add(new ListViewTopic(topics, category.getTopics()) { �...@override protected void populateItem(final ListItemTopic item) { final Topic topic = item.getModelObject(); final Label topicLabel = new Label(topic, topic.getName()); item.add(new AjaxLinkString(topicLink) { �...@override public void onClick(AjaxRequestTarget target) { item.add(topicLabel).add(new AttributeModifier(class, true, new AbstractReadOnlyModelString() { �...@override public String getObject() { return highlight; } })); target.addComponent(container); } }.add(topicLabel)); } }); } }); add(container); } Any other suggestions? Regards, Hbiloo On Wed, Jun 24, 2009 at 3:48 PM, Vasu Srinivasanvasy...@gmail.com wrote: 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 waarhei...@gmail.comwrote: 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;spanYeeh/span/a /li ... Does someone else already got the same issue? Regards, Hbiloo On Wed, Jun 24, 2009 at 12:36 PM, Vasu Srinivasanvasy...@gmail.com 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 waarhei...@gmail.com 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 ListViewCategory(categories, buildCategories()) { �...@override protected void populateItem(ListItemCategory item) { Category category = item.getModelObject(); item.add(new Label(category, category.getName())); item.add(new
Re: AttributeModifier not added to a ListView item via an AjaxLink
or *always* add the attribute modifier and only output the class value when needed. Martijn On Wed, Jun 24, 2009 at 5:13 PM, Martijn Dashorstmartijn.dasho...@gmail.com wrote: listview.setReuseItems(true) Martijn On Wed, Jun 24, 2009 at 5:03 PM, Azzeddine Daddahwaarhei...@gmail.com wrote: Thanks again Vasu, I've tried your solution but it does not work yet. Below my code: public TestPage() { final WebMarkupContainer container = new WebMarkupContainer(container); container.setOutputMarkupId(true); container.add(new ListViewCategory(categories, buildCategories()) { �...@override protected void populateItem(ListItemCategory item) { Category category = item.getModelObject(); item.add(new Label(category, category.getName())); item.add(new ListViewTopic(topics, category.getTopics()) { �...@override protected void populateItem(final ListItemTopic item) { final Topic topic = item.getModelObject(); final Label topicLabel = new Label(topic, topic.getName()); item.add(new AjaxLinkString(topicLink) { �...@override public void onClick(AjaxRequestTarget target) { item.add(topicLabel).add(new AttributeModifier(class, true, new AbstractReadOnlyModelString() { �...@override public String getObject() { return highlight; } })); target.addComponent(container); } }.add(topicLabel)); } }); } }); add(container); } Any other suggestions? Regards, Hbiloo On Wed, Jun 24, 2009 at 3:48 PM, Vasu Srinivasanvasy...@gmail.com wrote: 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 waarhei...@gmail.comwrote: 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;spanYeeh/span/a /li ... Does someone else already got the same issue? Regards, Hbiloo On Wed, Jun 24, 2009 at 12:36 PM, Vasu Srinivasanvasy...@gmail.com 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 waarhei...@gmail.com 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 ListViewCategory(categories, buildCategories()) { �...@override protected void populateItem(ListItemCategory item) {