Dynamically add components to ListView in Wicket

倾然丶 夕夏残阳落幕 提交于 2019-12-03 03:52:54

I suppose you already display a list of elements in a ListView? You than simply add new elements to the list that backup your ListView. Consider that the ListView will not refresh the items if you pass in the List in the constructor.

So, instead of

List<Person> personList = new LinkedList<Person>();
ListView<Person> personView = new ListView<Person("listview", personList);

you should use a Model that wraps the List:

ListView<Person> personView = new ListView<Person("listview"
               , new PropertyModel<List<Person>>(this, "personList");

along with a getPersonList() accessor in this.

You can have a look at Legup and generate the Wicket, Spring, JPA archetype. In the code you will find a EventPage that does this.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!