PDA

View Full Version : [FIXED] ListStore remove error



lucasas
5 Sep 2008, 3:50 AM
When the method remove(object) is invoked it remove the beanmodel object, but a throw java.lang.ArrayIndexOutOfBoundsException: -1 ocurred.

darrellmeyer
11 Sep 2008, 9:28 AM
Please post again using these guidelines (http://extjs.com/forum/showthread.php?t=40289) and including test code.

idajali
30 Sep 2008, 5:48 AM
GXT version: 1.1
Hosted/Web Mode: Both (stack trace reported in hosted mode)
Browser and version: Problem in both Firefox 3.0.3 and IE 7.0.5730.13
Operating System: Windows XP Professional

I am using a com.extjs.gxt.ui.client.widget.table.Table, a com.extjs.gxt.ui.client.binder.TableBinder, and a com.extjs.gxt.ui.client.store.ListStore.

When the method ListStore.remove(object) is invoked it removes the object, but throws the following exception (resulting in navigation problems in the table which persist until the sort is changed):

[ERROR] Uncaught exception escaped
java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.ArrayList.get(ArrayList.java:323)
at com.extjs.gxt.ui.client.widget.Container.getItem(Container.java:104)
at com.extjs.gxt.ui.client.widget.table.TableView.updateIndexes(TableView.java:577)
at com.extjs.gxt.ui.client.widget.table.TableView.removeItem(TableView.java:286)
at com.extjs.gxt.ui.client.widget.table.Table.remove(Table.java:462)
at com.extjs.gxt.ui.client.binder.TableBinder.onRemove(TableBinder.java:191)
at com.extjs.gxt.ui.client.binder.StoreBinder$1.storeRemove(StoreBinder.java:65)
at com.extjs.gxt.ui.client.store.StoreListener.handleEvent(StoreListener.java:36)
at com.extjs.gxt.ui.client.store.StoreListener.handleEvent(StoreListener.java:1)
at com.extjs.gxt.ui.client.event.BaseObservable.fireEvent(BaseObservable.java:74)
at com.extjs.gxt.ui.client.store.ListStore.remove(ListStore.java:327)
... 25 more


Tracking down the error, it appears that the code in the TableView.removeItem() method is trying to find the index of the removed item after it has been removed from the table. This is causing an index value of -1 and the above stack trace.

Sample code:

replace the following line in TableStorePage.java in the explorer app:

toolBar.add(new TextToolItem("Remove", "icon-delete"));

with:

TextToolItem remove;
toolBar.add(remove = new TextToolItem("Remove", "icon-delete"));
remove.addSelectionListener(new SelectionListener<ToolBarEvent>() {
public void componentSelected(ToolBarEvent event) {
store.remove(binder.getSelection().get(0));
}
});

darrellmeyer
30 Sep 2008, 7:52 PM
Fixed in SVN.