Shkfar
Shkfar

Reputation: 23

How to refresh a ListView, after changing the list to a new list?

I have a ListView with default lists in the page. I want the list to be replaced with certain conditions to a new list of content in the list view. Somehow I am able to set the list.

The problem is that I need to replace /refresh the listview with new list of items.

How can I accomplish that?

Upvotes: 0

Views: 87

Answers (1)

martin-g
martin-g

Reputation: 17533

You just need to update the model object: listView.setModelObject(List.of("new", "items")).

If you do this in an Ajax request then you will need to add the listView's parent component to the AjaxRequestTarget: target.add(listView.getParent()). You need to use the parent because repeater components render their markup for each item, so you need to re-render the markup that wraps the items.

Upvotes: 1

Related Questions