Change container in grid

It’s possible to change grid container on the fly? When I’m trying to do that, I have following exception:

Caused by: java.lang.NullPointerException: null
    at com.vaadin.data.RpcDataProviderExtension$GridValueChangeListener.removeListener(RpcDataProviderExtension.java:571) ~[vaadin-server-7.4.0.rc1.jar:7.4.0.rc1]

    at com.vaadin.data.RpcDataProviderExtension$ActiveRowHandler.removeValueChangeListeners(RpcDataProviderExtension.java:419) ~[vaadin-server-7.4.0.rc1.jar:7.4.0.rc1]

    at com.vaadin.data.RpcDataProviderExtension$ActiveRowHandler.access$1300(RpcDataProviderExtension.java:326) ~[vaadin-server-7.4.0.rc1.jar:7.4.0.rc1]

    at com.vaadin.data.RpcDataProviderExtension.setParent(RpcDataProviderExtension.java:991) ~[vaadin-server-7.4.0.rc1.jar:7.4.0.rc1]

    at com.vaadin.server.AbstractClientConnector.removeExtension(AbstractClientConnector.java:566) ~[vaadin-server-7.4.0.rc1.jar:7.4.0.rc1]

    at com.vaadin.ui.Grid.internalSetContainerDataSource(Grid.java:3217) ~[vaadin-server-7.4.0.rc1.jar:7.4.0.rc1]

    at com.vaadin.ui.Grid.setContainerDataSource(Grid.java:3198) ~[vaadin-server-7.4.0.rc1.jar:7.4.0.rc1]
​

Seeing your trace, it seems that you are providing a “null” instantiated object.

What are you aiming to do? Update the data of the grid?

I have exactly the same Problem. I want to update the content of the Grid by calling setContainerDataSource() with an own created Container.Indexed. Calling the first time everything works as expected. But the second time the mentioned Exception (same stacktrace) is thrown.

I’m using Grid component to display list of files attached with selected item.
When user changes item, new container is created and used as datasource for a grid…

@karpfen Unfortunately, official documentation doesn’t mention about above issue or limitation. I think this is bug.

Ok. There is a fix here:
http://dev.vaadin.com/changeset/294dc686f6d05dde90f852f46429b46c2f87af35/vaadin

Unfortunately, it will be included in next release.


http://dev.vaadin.com/ticket/16559

Thanks to both @Lukasz and @karpfen. I think my problem is similar… When I delete a row, the changes on the grid are not shown until I refresh the page. Addition of row elements are made using a Window (a modal window), and after adding one, results are not shown until I refresh the page…

In my case, I can confirm that the workaround solution stated in
http://dev.vaadin.com/ticket/16830
solved the reported issue.

The mentioned solution was simply to clear the container (.removeAllItems()), just before setting a new one in the grid.

And was helpful for me :slight_smile: Ty!