wicket-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Drummer, Matthias" <matthias.drum...@iqtig.org>
Subject AW: ListView
Date Thu, 24 May 2018 11:34:35 GMT

here some example code for refreshing a listView via an AjaxButton if I understood you right.
Perhaps it will help you.

Things to note:
- add the WebMarkupContainer to the AjaxRequestTarget (target.add(..)) not the ListView itself
because this will not work. You tried something like that in your example code.

public class TestPage extends WebPage {

    protected void onInitialize() {

        final List<String> pieces = new ArrayList<>();

        final WebMarkupContainer listViewContainer = new WebMarkupContainer("listViewContainer");

        listViewContainer.add(new ListView<String>("listView", Model.ofList(pieces))
            protected void populateItem(ListItem<String> item) {
                item.add(new Label("rowItem", item.getModel()));


        final Form<Void> form = new Form<>("testForm");

        form.add(new AjaxButton("refreshBtn") {

            int count = 0;
            protected void onSubmit(AjaxRequestTarget target) {

                // click adds a new rowItem
                pieces.add("Row Item String " + count);

                target.add(listViewContainer); // refresh the surrounding div container

<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
    <meta charset="UTF-8">
<div wicket:id="listViewContainer">
    <h2>ListView Container</h2>
    <div wicket:id="listView">
        <span wicket:id="rowItem">[RowItem]</span>
<form wicket:id="testForm">
    <input type="button" wicket:id="refreshBtn" value="Refresh ListView"/>

Greetings Matthias

-----Urspr√ľngliche Nachricht-----
Von: Maxim Solodovnik [mailto:solomax666@gmail.com] 
Gesendet: Donnerstag, 24. Mai 2018 12:32
An: users@wicket.apache.org
Betreff: Re: ListView

Could you share quickstart?

WBR, Maxim
(from mobile, sorry for the typos)

On Thu, May 24, 2018, 17:28 JavaTraveler <meteor.eisen@gmail.com> wrote:

> Hello !
> So no sorry, it does not work.
> The solution of Maxim does nothing different.
> And the one from Sven makes a mistake since my ListView needs a list 
> of pieces, and pieceModel is just a Piece.
> Any other solutions ?
> --
> Sent from:
> http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
View raw message