Dynamicznie dodawaj komponenty do ListView w Wicket

Chcę utworzyć formularz za pomocą przycisku „Dodaj”. Po naciśnięciu przycisku „Dodaj” nowy panel dodaje do elementu ListView furtki. Jak mogę to zrobić? Chcę być w stanie dodać nieograniczoną liczbę wierszy.

EDYTOWAĆ:

InteractivePanelPage.html

<table>
    <tr>
        <td><a href="#" wicket:id="addPanelLink">Add Panel</a></td>
    </tr>
    <tr wicket:id="interactiveListView">
        <td>
        <span wicket:id="interactiveItemPanel"></span>
        </td>
    </tr>
</table>

InteractivePanelPage.java

// ... imports
public class InteractivePanelPage extends WebPage {
    public LinkedList<InteractivePanel> interactivePanels = new LinkedList<InteractivePanel>();

    private ListView<InteractivePanel> interactiveList;

    public InteractivePanelPage() {
        add(new AjaxLink<String>("addPanelLink") {
            private static final long serialVersionUID = 1L;

            @Override
            public void onClick(AjaxRequestTarget target) {
                try {
                    System.out.println("link clicked");

                    InteractivePanel newInteractivePanel = new InteractivePanel(
                            "interactiveItemPanel");
                    newInteractivePanel.setOutputMarkupId(true);

                    interactiveList.getModelObject().add(newInteractivePanel);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        interactivePanels.add(new InteractivePanel("interactiveItemPanel"));

        interactiveList = new ListView<InteractivePanel>("interactiveListView",
                new PropertyModel<List<InteractivePanel>>(this, "interactivePanels")) {
            private static final long serialVersionUID = 1L;

            @Override
            protected void populateItem(ListItem<InteractivePanel> item) {
                item.add(item.getModelObject());
            }
        };

        interactiveList.setOutputMarkupId(true);

        add(interactiveList);
    }

    public List<InteractivePanel> getInteractivePanels() {
        return interactivePanels;
    }
}

InteractivePanel.html

<html xmlns:wicket>
<wicket:panel>
<span><input type="button" value="BLAAA" wicket:id="simpleButton"/></span>
</wicket:panel>
</html>

InteractivePanel.java

// ... imports
public class InteractivePanel extends Panel {
    private static final long serialVersionUID = 1L;

    public InteractivePanel(String id) {
        super(id);

        add(new Button("simpleButton"));
    }
}

To po prostu nie działa. Czy ktoś może zobaczyć dlaczego? Dzięki

questionAnswers(1)

yourAnswerToTheQuestion