Dynamically add components to ListView in Wicket

前端 未结 1 505
小蘑菇
小蘑菇 2021-02-06 15:00

I want to make a form with \"Add\" button. After pressing \"Add\" button new panel adds to the wicket ListView element. How do I do that? I want to be able add unlimited number

1条回答
  •  感动是毒
    2021-02-06 15:03

    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 personList = new LinkedList();
    ListView personView = new ListView

    you should use a Model that wraps the List:

    ListView personView = new ListView>(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.

    0 讨论(0)
提交回复
热议问题