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
Hi,

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 {

    @Override
    protected void onInitialize() {
        super.onInitialize();

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

        final WebMarkupContainer listViewContainer = new WebMarkupContainer("listViewContainer");
        listViewContainer.setOutputMarkupId(true);

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

        add(listViewContainer);

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

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

            int count = 0;
            @Override
            protected void onSubmit(AjaxRequestTarget target) {
                super.onSubmit(target);

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

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

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

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
>
>
Mime
View raw message