Re: adding items dynamically to ListView
Just resolved the issue. The problem was that I wasnt setting container.setOutputMarkupId(true); before I initially added the container to the page. I was setting it when the user clicked a button, which always occurred after the container was initially added. My original flow was something like this: WicketPanel class { ... instantiate container ajax onClick() { container.setOutputMarkupId(true); target.addComponent(container) } add(container) } It needs to be like this: WicketPanel class { ... instantiate container container.setOutputMarkupId(true); ajax onClick() { target.addComponent(container) } add(container) } Makes sense. Thanks for all the help -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/adding-items-dynamically-to-ListView-tp3580840p3582682.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
adding items dynamically to ListView
I'm trying to add items to a listView when a user clicks a button. I have a propertyModel backing my ListView. In the onClick(), I do: AjaxLink newIncButton = new AjaxLink(newIncButton){ @Override public void onClick(AjaxRequestTarget target) { List list = new ArrayList(bean.getIncList()); Incident inc = new Incident(); inc.setAction(action); inc.setDescription(whatever description); list.add(0, inc); bean.setIncList(list); } } the variable bean is the object which backs the propertyModel. The ListView doesn't appear to be refreshing with the new item I put in the list. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/adding-items-dynamically-to-ListView-tp3580840p3580840.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: adding items dynamically to ListView
sorry, trying to format that AjaxLink newIncButton = new AjaxLink(newIncButton){ @Override public void onClick(AjaxRequestTarget target) { List list = new ArrayList(bean.getIncList()); Incident inc = new Incident(); inc.setAction(action); inc.setDescription(whatever description); list.add(0, inc); bean.setIncList(list); } } -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/adding-items-dynamically-to-ListView-tp3580840p3580846.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: adding items dynamically to ListView
On Tue, Jun 7, 2011 at 11:20 PM, wmike1...@gmail.com wmike1...@gmail.com wrote: sorry, trying to format that AjaxLink newIncButton = new AjaxLink(newIncButton){ @Override public void onClick(AjaxRequestTarget target) { List list = new ArrayList(bean.getIncList()); Incident inc = new Incident(); inc.setAction(action); inc.setDescription(whatever description); list.add(0, inc); bean.setIncList(list); listView.modelChanged(); target.addComponent(listView); } } -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/adding-items-dynamically-to-ListView-tp3580840p3580846.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: adding items dynamically to ListView
Wicket doesn't allow me to update a ListView object directly through ajax, it suggests putting it in in a container. So I made a WebMarkupContainer to wrap the ListView. I have now: public void onClick(AjaxRequestTarget target) { List list = new ArrayList(bean.getIncList()); Incident inc = new Incident(); inc.setAction(action); inc.setDescription(whatever description); list.add(inc); bean.setIncList(list); listView.modelChanged(); container.modelChanged(); container.setOutputMarkupId(true); listView.setOutputMarkupId(true); container.add(listView); target.addComponent(container); } I've confirmed that the model is being updated. The component is still not being redrawn. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/adding-items-dynamically-to-ListView-tp3580840p3580990.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: adding items dynamically to ListView
How do you set up the model? Can we see some code? Sent from tablet device. Please excuse typos and brevity. On Jun 7, 2011 6:13 PM, wmike1...@gmail.com wmike1...@gmail.com wrote: Wicket doesn't allow me to update a ListView object directly through ajax, it suggests putting it in in a container. So I made a WebMarkupContainer to wrap the ListView. I have now: public void onClick(AjaxRequestTarget target) { List list = new ArrayList(bean.getIncList()); Incident inc = new Incident(); inc.setAction(action); inc.setDescription(whatever description); list.add(inc); bean.setIncList(list); listView.modelChanged(); container.modelChanged(); container.setOutputMarkupId(true); listView.setOutputMarkupId(true); container.add(listView); target.addComponent(container); } I've confirmed that the model is being updated. The component is still not being redrawn. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/adding-items-dynamically-to-ListView-tp3580840p3580990.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org