Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Grid problem when updating to Vaadin 7.6.1
We are currently using Vaadin 7.5.9 with spring boot 1.3.1 and we are now trying to upgrade tot he latest version of vaadin, that is 7.6.1 if am not mistaken. Doing this we ran into a problem with the grid and I would love it if you could tell us with we need to do something different with the new version.
What we are doing is that we have some data in the grid that is jpa entities that we grab from the database. This works well int he current version. We use MVP and in the presenter we call a spring service to get the entities.
And the problem is that when we do a delete we get a:
at com.vaadin.data.util.GeneratedPropertyContainer$GeneratedPropertyItem.getItemProperty(GeneratedPropertyContainer.java:144) ~[vaadin-server-7.6.1.jar:7.6.1]
and in the vaadin client side debugger we see:
Error performing server to cleint RPC calls java.lang.IndexOutOfBoundsException: The given row range (0..21) was outside the current number of rows (20)
What we do in the delete function is that we call the spring services to delete the current entity fromt he db and then we ask the grid to be refreshed by calling the underlying BeanItemController and removing all items and then fetch the entities from the db again and add them to the BeanItemController. Not the most efficient way but simple, in this case it doesn't need to be efficient.
In this case we had 21 rows in the grid before the delete and then 20 after deletion.
Should we do this in a different manner with the new version? What is the recommended way?
try to recreate your container
Well, I tried it and it works. I dont get the exception but.... is it really a proper solution?
My problem is that I have a few columns with some icons that are added to the container as generatedProperty with it's own widget. I would need to waste clockcycles on recreateing these everytimes that a refresh is done...
I have been having the exact same problem and have been struggeling with it for days. I think the problem is a bug related to the selection model being out of sync with the grid data source. After the item is deleted, a push notification arrives asyncronously. This push notification triggers a process that seems to be trying to retreive the items from the grid data source that where just removed. This results in the null pointer exception.
Try adding the following line after deleting the items from the grid. Change the selection mode to whatever mode your using.
This results in the creation of a new selection model, which seems to be a workaround for this bug.