PDA

View Full Version : Use HttpProxy and TreeLoader has error,how to solve the problem?thanks



tang9528
19 Aug 2008, 8:18 AM
try {
ModelType type = new ModelType();
type.root = "fileInfo";
type.addField("name");
type.addField("size");
HttpProxy proxy = new HttpProxy(new RequestBuilder(RequestBuilder.GET,"tree.js"));
TreeLoader loader = new BaseTreeLoader(proxy, new JsonReader(type));
TreeStore store = new TreeStore(loader);//if not this,it's ok
loader.load();
}catch(Exception error){
Log.warn("error:" + error.getMessage());//Log source from com.allen_sauer.gwt.log.client.Log
}




tree.js
{"fileInfo":[{"name": "\u6d4b\u8bd5.doc","size": 1024}, {"name": "dbhelper.html","size": 1024}, {"name": "a+p+m","size": 0}, {"name": "\u4f60\u597d.pptx","size": 1034}]}


however have such error


Uncaught Exception: java.lang.RuntimeException: java.lang.ClassCastException Caused by: java.lang.ClassCastException: null



how to solve the problem?




thanks

tang9528
20 Aug 2008, 6:43 AM
i find

Jsonreader.java

public ListLoadResult read(C loadConfig, Object data)

TreeStore.java

protected void onLoad(TreeLoadEvent le) {
.....
for (M model : (List<M>) le.data)
.....
}

le.data is ListLoadResult not List<M> lead the error.

so,i extend the JsonReader.java



public ArrayList<ModelData> read(C loadConfig, Object data)


Demo has realize

1)rails providing json data
2)tree node dynamic loading

detail please access attachments.