Wicket: How to change contents of PageableListView dynamically?

432 Views Asked by At

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:

  1. As mentioned in this link, I tried using pageableListView.removeAll(); and setting pageableListView.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();
        }
};
1

There are 1 best solutions below

4
Andrea Del Bene On BEST ANSWER

you seem to forget adding pageableListView to AjaxRequestTarget target in order to refresh your PageableListView.