1
votes

I would like to as you some question about SimplePager object of GWT. So I got special list of items which implements HasRows interface to be able to use paging. But the problem is that list can increase size without integration of user. And then element will be added to the list, the SimplePager size should be increases as well. But I would like to avoid refreshing whole page and update only parger.

So currently when I am initializing site I am calling:

pager.setDisplay(customList);

And doing nothing when list is growing. So I thought that I could use same method when item is added to the list.

for example:

public void onItemAdded(Person person){
    customList.add(person);
    pager.setDisplay(customList);
}

But it is not redrawing widget, and only after the user refresh site it is initializing widgets again and getting proper amount of items in list.

Any idea how could i force update on pager itself?

1

1 Answers

0
votes

You should use a ListDataProvider<Person>, between your list and the pager:

ListDataProvider<Person> dataProvider = new ListDataProvider<Person>();
dataProvider.setDataDisplay(customList);
pager.setDisplay(customList);

and then your function for adding an item will be:

public void onItemAdded(Person person){
    dataProvider.getList().add(person);
}

By setting the dataDisplay, each operation on the underlying list will be updated on this display. See http://www.gwtproject.org/javadoc/latest/com/google/gwt/view/client/ListDataProvider.html