Caused by: java.lang.IllegalArgumentException: Item with specified ID does

Hi,

I have use grid in my panel with delete column and one add button in panel which add the new row in grid.
when I delete the row from grid then it works, but when I add a new item then some times it gives following Exception.

I have refresh the grid while deleteing the item.
@Override
public void refresh() {
locoContainer.removeAllItems();
locoContainer.addAll(dataList);
}


Exception:

[i]
Caused by: java.lang.IllegalArgumentException: Item with specified ID does not exist in data source
at com.vaadin.ui.Grid.scrollTo(Grid.java:5408)[69:com.vaadin.server:7.6.5]

at com.vaadin.ui.Grid.scrollTo(Grid.java:5386)[69:com.vaadin.server:7.6.5]

at com.knorrbremse.icom.leader.ui.components.grid.RestoreSelectionListener.selectByBean(RestoreSelectionListener.java:64)
at com.knorrbremse.icom.leader.ui.components.grid.RestoreSelectionListener.detach(RestoreSelectionListener.java:77)
at sun.reflect.GeneratedMethodAccessor89.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)[:1.8.0_40]

at java.lang.reflect.Method.invoke(Unknown Source)[:1.8.0_40]

at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:508)[69:com.vaadin.server:7.6.5]

... 57 more

[/i]

Is any pointer to solve this problem?

It looks like you are having some other code that is using that Grid too in event handling. One of your events seems perform scrollTo() certain item. Now my best guess is that at the same time event is run, you are deleting the items from the container. Hence scrollTo() gives exception since the item is not in the container anymore.

Thanks Tatu Lund,

kindly tell me how can I handle this exception?

on delete action I have to remove the item from container and refresh it.

Another thing is it does not through exception each time.it occors randomly.