alejandro-du / crudui

Automatically generate CRUD-like Vaadin views for any Java Bean
https://vaadin.com/directory#!addon/crud-ui-add-on
Apache License 2.0
85 stars 52 forks source link

Crud grid not updated after new item creation #29

Closed ekomrak closed 6 years ago

ekomrak commented 6 years ago

I found an issue with the following case. I use crud.setFindAllOperation to pass a collection of objects to the crud grid. Then I add a new item to the collection on the server side (not using Crud functionality). I expect that grid will be automatically refreshed and a new row will be added. Current Crud implementation breaks this case. Setting items to the grid in refreshGrid method (grid.setItems(items);) breaks automatic refresh of the grid by Vaadin NotificationListeners. I suggest to rewrite attach and refreshGrid methods in the following way:

@Override
public void attach() {
    super.attach();
    items = findAllOperation.findAll();
    grid.setItems(items);
}

public void refreshGrid()
{
    grid.getDataProvider().refreshAll();
}
ekomrak commented 6 years ago

Sorry, it was an issue in my code. Please ignore this issue