Apache Wicket > Framework Documentation > Reference library > How to do things in Wicket > Forms > Using listviews
Added by Confluence Administrator, last edited by Will Hoover on Mar 07, 2008  (view change)

When using ListViews in forms, you have to be careful that you set the reuseItems property of the ListView to true (it is false by default). If you don't do this, the components are removed and added again (new instances) everytime, and you will not see any invalid input if your form did not validate.

Set this property e.g. like:

private final class MyListView extends ListView
{
	private MyListView(String id)
	{
		super(id);
		setReuseItems(true);
	}
...

If you need to delete items from the list don't forget to call detach() after the deletion is made:

item.add(new Link("delete") {
         @Override public void onClick() {
                 myDao.delete(item.getModelObject());
                 listview.detach();
         }
  });