I'm building a project based on the CRUD example of vaadin 8.
I have a grid that opens a form on the right side of my page, this form has a cancel button that close this form and clear the grid selection.
I'm getting this error:
com.vaadin.event.ListenerMethod$MethodException: Invocation of method selectionChange in com.vaadin.ui.components.grid.SingleSelectionModelImpl$2$$Lambda$352/1190062771 failed.
This is the stackTrace:
com.vaadin.event.ListenerMethod$MethodException: Invocation of method selectionChange in com.vaadin.ui.components.grid.SingleSelectionModelImpl$2$$Lambda$352/1190062771 failed.
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:519)
at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:273)
at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:237)
at com.vaadin.server.AbstractClientConnector.fireEvent(AbstractClientConnector.java:1014)
at com.vaadin.ui.components.grid.SingleSelectionModelImpl.setSelectedFromServer(SingleSelectionModelImpl.java:179)
at com.vaadin.ui.components.grid.SingleSelectionModelImpl.deselect(SingleSelectionModelImpl.java:90)
Caused by: java.lang.NullPointerException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
Any idea? My object is not null.
public void clearSelection() {
try {
grid.getSelectionModel().deselectAll();
} catch (Exception e) {
e.printStackTrace();
}
}
My grid init code on the view class:
grid = new GridViagem();
grid.setDataProvider(dataProvider);
grid.asSingleSelect().addValueChangeListener(
event -> viewLogic.rowSelected(event.getValue()));