PDA

View Full Version : Async TreePanel loading probs, pls help



dealy663
24 Nov 2009, 9:51 AM
I had a working tree panel that was originally just populated with modeldatas everything was fine until I decided that I needed to dynamically add sub nodes to the existing tree elements. Looking through the examples I found GXT Async Tree and tried converting my TreePanel to use that form of loading.

I'm not getting any errors, its just that nothing ever is displayed in the tree. Tracing through my code I see that RpcProxy.load() is being called, and that function I've overloaded to go and fetch the latest modeldatas, passing a list of them to the callback param of RpcProxy.load().

I just can't find what is wrong here, Its been a couple of days and I'm at my wit's end.



public class VRowHeader extends BaseModel {... }

public class VRowTree extends TreePanel<VRowHeader> {
public static void getChildren(final VRowHeader parentRow, final AsyncCallback<List<VRowHeader>> callback) {
...
Invoke.getvRowTree(parentRowID, decoratorClass, new WebResponseCallback() {
@Override
public void onResponse(WebResponse webResponse) {
List<VRowHeader> hdrList = new ArrayList<VRowHeader>();
JSONArray response = (JSONArray)webResponse.getMap().get("entryHeaders");

for(int i = 0; i < response.size(); i++) {
VRowHeader row = SerializableUtils.toBaseModelData(new VRowHeader(),
response.get(i).isObject());
hdrList.add(row);
}

callback.onSuccess(hdrList);
}
});

}

}
RpcProxy<List<VRowHeader>> proxy = new RpcProxy<List<VRowHeader>>() {
@Override
protected void load(Object header, AsyncCallback<List<VRowHeader>> callback) {
VRowTree.getChildren((VRowHeader) header, callback);
}
};

BaseTreeLoader<VRowHeader> loader = new BaseTreeLoader<VRowHeader>(proxy) {
@Override
public boolean hasChildren(VRowHeader parent) {
return (parent.getChildCount() > 0);
}
};

TreeStore<VRowHeader> store = new TreeStore<VRowHeader>(loader);
store.setKeyProvider(new ModelKeyProvider<VRowHeader>() {
public String getKey(VRowHeader model) {
return model.getRowID();
}
});

vRowTree = new VRowTree(store);
ContentPanel west = new ContentPanel();
west.setHeading("Farms");
west.setLayout(new FitLayout());
west.add(vRowTree);
west.layout();

Any help, suggestions, or pointers to more complete examples than AsyncTree would be really really appreciated.

Thanks, Derek