I have a html page with a search field and a table view displayed using PageableListView.
The data is present in userListForTable list.
In the onSubmit() method of the AjaxButton searchButton, thedbService.getEmployeeByName(searchInputString) method returns a new list which I assign it to the userListForTable object.
While doing this, I assumed that when I assign a new list to userListForTable, the PageableListView table would be updated automatically but this is not happening.
Can anyone please help with it?
Efforts:
- As mentioned in this link, I tried using
pageableListView.removeAll();and settingpageableListView.setReuseItems(true);
Code:
pageableListView = new PageableListView<UserModel>("rows", new PropertyModel<List<UserModel>>(this, "userListForTable" ), 8) {
private static final long serialVersionUID = 1L;
private ModalWindow modalWindow;
@Override
protected void populateItem(ListItem<UserModel> arg0) {
// TODO Auto-generated method stub
final UserModel userModel = (UserModel) arg0.getDefaultModelObject();
arg0.add(new Label("name", userModel.getName()));
arg0.add(new Label("gender", userModel.getGender()));
}
}
The searchButton
AjaxButton searchButton = new AjaxButton("searchButton") {
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
// TODO Auto-generated method stub
super.onSubmit();
//get search string
searchInputString = searchInput.getSearchString();
//clear userListForTable and populate new List items
userListForTable = null;
userListForTable = dbService.getEmployeeByName(searchInputString);
pageableListView.removeAll();
}
};
you seem to forget adding
pageableListViewtoAjaxRequestTarget targetin order to refresh yourPageableListView.