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:[email protected]]
Gesendet: Donnerstag, 24. Mai 2018 12:32
An: [email protected]
Betreff: Re: ListView
Could you share quickstart?
WBR, Maxim
(from mobile, sorry for the typos)
On Thu, May 24, 2018, 17:28 JavaTraveler <[email protected]> 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: [email protected]
> For additional commands, e-mail: [email protected]
>
>