PDA

View Full Version : [FIXED] CheckBox in grid causes null pointer exception



andreea.spirea
11 May 2009, 6:20 AM
Hi,

I am trying to render an EditorGrid, with a CheckColumnConfig column. The column gets rendered, checking works, but unchecking causes a null pointer exception with the following trace:

[ERROR] Uncaught exception escaped
java.lang.NullPointerException: null
at com.extjs.gxt.ui.client.store.Record.set(Record.java:269)
at com.extjs.gxt.ui.client.widget.grid.CheckColumnConfig.onMouseDown(CheckColumnConfig.java:112)
at com.extjs.gxt.ui.client.widget.grid.CheckColumnConfig$1.handleEvent(CheckColumnConfig.java:67)
at com.extjs.gxt.ui.client.widget.grid.CheckColumnConfig$1.handleEvent(CheckColumnConfig.java:1)
at com.extjs.gxt.ui.client.event.BaseObservable.fireEvent(BaseObservable.java:100)
at com.extjs.gxt.ui.client.widget.Component.fireEvent(Component.java:455)
at com.extjs.gxt.ui.client.widget.grid.Grid.onMouseDown(Grid.java:601)
at com.extjs.gxt.ui.client.widget.grid.Grid.onComponentEvent(Grid.java:373)
at com.extjs.gxt.ui.client.widget.Component.onBrowserEvent(Component.java:758)
at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1320)
at com.google.gwt.user.client.DOM.dispatchEventAndCatch(DOM.java:1299)
at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1262)
at sun.reflect.GeneratedMethodAccessor40.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod(IDispatchImpl.java:126)
at com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:155)
at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:294)
at com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:194)
at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1925)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2966)
at com.google.gwt.dev.SwtHostedModeBase.processEvents(SwtHostedModeBase.java:235)
at com.google.gwt.dev.HostedModeBase.pumpEventLoop(HostedModeBase.java:558)
at com.google.gwt.dev.HostedModeBase.run(HostedModeBase.java:405)
at com.google.gwt.dev.HostedMode.main(HostedMode.java:232)



Also, clicking it the second time does make the checkmark appear.
A quick fix seems to be, for my checkColumnConfig:

CheckColumnConfig checkColumnConfig = new CheckColumnConfig(
SecurityConstants.ASSIGNED, "assgined", 20) {
protected void onMouseDown(GridEvent<ModelData> ge) {
String cls = ge.getTarget().getClassName();
if (cls != null && cls.indexOf("x-grid3-cc-" + getId()) != -1 && cls.indexOf("disabled") == -1) {
ge.stopEvent();
int index = grid.getView().findRowIndex(ge.getTarget());
ModelData m = grid.getStore().getAt(index);
Record r = grid.getStore().getRecord(m);
boolean b = (Boolean) m.get(getDataIndex());
r.setValid(getDataIndex(), true);
r.set(getDataIndex(), !b);
}
}
};

Thanks.

sven
11 May 2009, 6:27 AM
This was already reported before and is fixed in SVN