PDA

View Full Version : [FIXED] NullPointerException when clicking within DataList



smill
12 Aug 2008, 7:09 PM
- Detailed description of the problem
If you have a resized DataList with some free space (without elements e.g.) and click within the free space, you get a NullPointerException on your GWT log.

- GXT version
Latest from SVN, 696

- Host mode / web mode / both
Just figured it out in hosted mode

- Browser and version
GWT's usual browser, IE 7

- Operating System
Win Vista

- Sample code



DataList list = new DataList();
list.setSize(100, 100);
- Stack trace



[ERROR] Uncaught exception escaped
java.lang.NullPointerException: null
at com.extjs.gxt.ui.client.widget.DataListSelectionModel.onClick(DataListSelectionModel.java:49)
at com.extjs.gxt.ui.client.widget.selection.AbstractSelectionModel.handleEvent(AbstractSelectionModel.java:153)
at com.extjs.gxt.ui.client.widget.selection.AbstractSelectionModel.handleEvent(AbstractSelectionModel.java:1)
at com.extjs.gxt.ui.client.event.BaseObservable.fireEvent(BaseObservable.java:74)
at com.extjs.gxt.ui.client.widget.Component.fireEvent(Component.java:420)
at com.extjs.gxt.ui.client.widget.Component.onBrowserEvent(Component.java:636)
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.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

adam.schwartz
13 Aug 2008, 7:52 AM
I've had this same issue as well. In the DataListSelectionModels' onClick(...) just checking to ensure item is not null before you use it, you'll be safe.



@Override
protected void onClick(ContainerEvent ce) {
if (!selectOnCheck) {
DataListItem item = (DataListItem) ce.item;

if( item == null )
return;

El e = item.el().selectNode(".my-list-item-icon");
if (e != null && ce.within(e.dom)) {
return;
}
}
super.onClick(ce);
}

darrellmeyer
13 Aug 2008, 11:02 AM
Fix is in SVN.