PDA

View Full Version : Exception using CheckBoxSelectionModel



Ltty
7 Nov 2011, 8:29 AM
Whenever I use the CheckBoxSelectionModel I get a NPE the first time a data grid loads. However, if I reload the grid using Ctrl + F5, everything works out fine. This is what I get:




java.lang.NullPointerException: null
at com.extjs.gxt.ui.client.widget.grid.CheckBoxSelectionModel$2.handleEvent(CheckBoxSelectionModel.java:80)
at com.extjs.gxt.ui.client.widget.grid.CheckBoxSelectionModel$2.handleEvent(CheckBoxSelectionModel.java:1)
at com.extjs.gxt.ui.client.event.BaseObservable.callListener(BaseObservable.java:178)
at com.extjs.gxt.ui.client.event.BaseObservable.fireEvent(BaseObservable.java:86)
at com.extjs.gxt.ui.client.widget.Component.fireEvent(Component.java:456)
at com.extjs.gxt.ui.client.widget.Component.fireEvent(Component.java:439)
at com.extjs.gxt.ui.client.widget.grid.Grid.afterRenderView(Grid.java:728)
at com.extjs.gxt.ui.client.widget.grid.Grid$1.run(Grid.java:711)
at com.google.gwt.user.client.Timer.fire(Timer.java:149)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:213)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Thread.java:662)

My code:


grid = new Grid<BeanModel>(model, colDef);

selectionModel = new CheckBoxSelectionModel<BaseModel>();
this.add(selectionModel.getColumn());
...

grid.setAutoExpandColumn(autoExpandValue);
grid.setAutoHeight(true);
grid.setBorders(true);
grid.setSelectionModel(selectionModel);
grid.addPlugin(selectionModel);
table.add(grid);

sven
7 Nov 2011, 1:16 PM
Have you tried to reproduce this in a small, standalone testcase implementing EntryPoint? It would be good to understand why you get the exception.

Ltty
8 Nov 2011, 4:38 AM
It seems that there is a problem if I assign the content panel to an element within the UiBinder. I could fix this by reassigning and recreating the table whenever I get new grid data.

sven
8 Nov 2011, 4:47 AM
If you could provide a testcase that we could simple run, than we would really like to fix this issue. But to fix this, we first need to understand the problem. Normally when the ViewReady event fires, the gridview should already have a columnheader (which seems to be null in your case, but i am just guessing).

Ltty
8 Nov 2011, 11:24 PM
Here is the code that caused the problem. I provide the ColumnModel from an external factory to keep the table widget modular. In order to get the code working, I just put the stuff from the constructor to the initialize method.

The same issue occurs if I place the table.setTopComponent(toolBar); command directly in the setToolbar() method. Don't worry, I checked if I called the setToolbar() method before the initialize() method. If you do that the toolbar only appears if you reload the example a second time. However, this does not throw an exception.

29163