PDA

View Full Version : [OPEN] Beta 4, NPE when updating table with new info with Sort



Orion-
21 May 2008, 6:52 AM
When I use a loader to show data in a table, it works fine. When I then use the same loader again to get other info to show in the same table, I get a NPE (see stack trace). This seems due to the fact that the item list is still from the previous data, and not the new one. I make this supposition due to the fact that the row variable in TableBinder.onSort still has the old value.


Thread [main] (Suspended (exception NullPointerException))
TableBinder<M>.onSort(StoreEvent) line: 167
StoreBinder$1.storeSort(StoreEvent) line: 68
StoreTypedListener.handleEvent(BaseEvent) line: 29
ListStore<M>(BaseObservable).fireEvent(int, BaseEvent) line: 75
ListStore<M>.applySort() line: 373
ListStore<M>.onLoad(LoadEvent) line: 154
ListStore$1.loaderLoad(LoadEvent) line: 130
LoadTypedListener.handleEvent(BaseEvent) line: 34
BaseListLoader<C,D>(BaseObservable).fireEvent(int, BaseEvent) line: 75
BaseListLoader<C,D>.onLoadSuccess(C, D) line: 124
BaseListLoader<C,D>.onLoadSuccess(Object, Object) line: 1
BaseLoader$1.onSuccess(D) line: 111
RpcProxy$1.onSuccess(Object) line: 33
RequestCallbackAdapter<T>.onResponseReceived(Request, Response) line: 210
Request.fireOnResponseReceivedImpl(RequestCallback) line: 254
Request.fireOnResponseReceivedAndCatch(GWT$UncaughtExceptionHandler, RequestCallback) line: 226
Request.fireOnResponseReceived(RequestCallback) line: 217
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
Method.invoke(Object, Object...) line: 597
MethodAdaptor.invoke(Object, Object...) line: 103
MethodDispatch.invoke(int, int[], int) line: 80
OS._g_main_context_iteration(int, boolean) line: not available [native method]
OS.g_main_context_iteration(int, boolean) line: 1428
Display.readAndDispatch() line: 2840
GWTShell.pumpEventLoop() line: 745
GWTShell.run() line: 608
GWTShell.main(String[]) line: 375

darrellmeyer
2 Jun 2008, 9:48 PM
There should not be any issues with beta 4. The Xml Table demo in the Explorer demo allows you to reload a table's data via its loader. If you still get exceptions, post some sample code and we will take a look.

Orion-
3 Jun 2008, 5:56 AM
Hello,

as my previous stack traced showed it, the NPE occurs during the sort. To create a test case, I took the code from the XmlTable sample and added a default sort and a StoreSorter to the ListStore. The code is below. To trigger the bug, click the "Load XML" button, wait for the result to show, and then click it again.

For my test, I created a sample file data.xml with just 4 rows. If I should add more info to this report, just ask.

I used GXT Beta 4 with GWT 1.5 RC 1.

Orion-



public void onModuleLoad() {
RootPanel.get().add(this);
}

@Override
protected void onRender(Element parent, int pos) {
super.onRender(parent, pos);

setLayout(new FlowLayout(10));

List<TableColumn> columns = new ArrayList<TableColumn>();
columns.add(new TableColumn("Sender", .2f));
columns.add(new TableColumn("Email", .4f));
columns.add(new TableColumn("Phone", .2f));
columns.add(new TableColumn("State", .1f));
columns.add(new TableColumn("Zip", "Zip Code", .1f));

// create the column model
TableColumnModel cm = new TableColumnModel(columns);
final Table table = new Table(cm);

// defines the xml structure
ModelType type = new ModelType();
type.root = "records";
type.recordName = "record";
type.addField("Sender", "Name");
type.addField("Email");
type.addField("Phone");
type.addField("State");
type.addField("Zip");

// use a http proxy to get the data
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, "data.xml");
HttpProxy proxy = new HttpProxy(builder);

// need a loader, proxy, and reader
XmlReader reader = new XmlReader(type);

final BaseListLoader loader = new BaseListLoader(proxy, reader);

ListStore store = new ListStore(loader);
store.setDefaultSort("Sender", Style.SortDir.ASC);
store.setStoreSorter(new StoreSorter() {
@Override
public int compare(
Store store, ModelData i1, ModelData i2, String property) {
return 0;
}
});
new TableBinder(table, store);

ContentPanel panel = new ContentPanel();
panel.setFrame(true);
panel.setCollapsible(true);
panel.setAnimCollapse(false);
panel.setButtonAlign(HorizontalAlignment.CENTER);
panel.setIconStyle("icon-table");
panel.setHeading("XML Table Demo");
panel.setLayout(new FitLayout());
panel.add(table);
panel.setSize(575, 350);

// add buttons
Button load = new Button("Load XML");
load.addSelectionListener(new SelectionListener() {
@Override
public void componentSelected(ComponentEvent ce) {
loader.load();
}
});
panel.addButton(load);
add(panel);

}