PDA

View Full Version : [FIXED] DataList.onCheckChange throws NullPointerException



liukaipeng
9 Sep 2008, 6:27 PM
- Sample code
final DataList list = new DataList();
list.setScrollMode(Scroll.AUTO);
list.setBorders(false);
list.setFlatStyle(true);
//list.setCheckable(true);
...

- Detailed description of the problem
I use DataList to display a list for selection. When checking one of the item in the list, I encounter the following error sometimes (yes, sometimes, not reproducable, but it do happen):

[ERROR] Uncaught exception escaped
java.lang.NullPointerException: null
at com.extjs.gxt.ui.client.widget.DataList.onCheckChange(DataList.java:501)
at com.extjs.gxt.ui.client.widget.DataListItem.setChecked(DataListItem.java:125)
at com.extjs.gxt.ui.client.widget.DataList.onClick(DataList.java:514)
at com.extjs.gxt.ui.client.widget.DataList.onComponentEvent(DataList.java:341)
at com.extjs.gxt.ui.client.widget.Component.onBrowserEvent(Component.java:652)
at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1308)
at com.google.gwt.user.client.DOM.dispatchEventAndCatch(DOM.java:1287)
at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1255)
at sun.reflect.GeneratedMethodAccessor28.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.GWTShell.pumpEventLoop(GWTShell.java:720)
at com.google.gwt.dev.GWTShell.run(GWTShell.java:593)
at com.google.gwt.dev.GWTShell.main(GWTShell.java:357)

The code of DataList.onCheckChange:

protected void onCheckChange(DataListItem item, boolean checked) {
String s = checked ? "my-list-checked" : "my-list-notchecked";
item.checkBtn.changeStyle(s);
if (checked) {
this.checked.add(item);
} else {
this.checked.remove(item);
}
fireEvent(Events.CheckChange, new DataListEvent(this, item));
}

The second line use item.checkBtn without check. Through an uncomplete search within the code, I discovered that if I don't use list.setCheckable(true) to make the list checkable, the item.checkBtn won't be initialized. However, if it is the cause, then why doesn't it happen all the time?

- GXT version
1.1-alpha4

- Host mode / web mode / both
both

- Browser and version
IE6/7

- Operating System
Windows2003

darrellmeyer
11 Sep 2008, 7:19 AM
Fixed in SVN.