how to use the treestore
hello everyone!
now
i want to use the gxt3 tree but the childeren nodes i didn't know how to create
my programs like this:






public class PermissionAllocation extends Window {
private TreeLoader loader;
private TreeStore<JsonData> store;




private final String URL_OF_PERMISSION = GWT.getHostPageBaseURL() + "permission!list.do";




public PermissionAllocation() {
this.store=createStore();
this.loader=createLoader();
init();
}
public TreeStore<JsonData> createStore(){
return new TreeStore<JsonData>(new KeyProvider());
}
public TreeLoader<JsonData> createLoader() {
JsonTreeAutoBeanFactory factory = GWT.create(JsonTreeAutoBeanFactory.class);
DataRecordJsonReader reader = new DataRecordJsonReader(factory, JSonDataRecordResult.class);


RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, URL_OF_PERMISSION);
HttpProxy<JsonData> jsonProxy = new HttpProxy<JsonData>(requestBuilder);
jsonProxy.setWriter(new UrlEncodingWriter<JsonData>(factory, JsonData.class));
final TreeLoader<JsonData> loader = new TreeLoader<JsonData>(jsonProxy, reader) {
@Override
public boolean hasChildren(JsonData parent) {
return (null!=parent.getParent()&&"true".equals(parent.getParent()));
}
};


loader.addLoadHandler(new ChildTreeStoreBinding<JsonData>(store));
return loader;
}


private Tree<JsonData, String> createTree() {

Tree<JsonData, String> tree = new Tree<JsonData, String>(store, new ValueProvider<JsonData, String>() {


@Override
public String getValue(JsonData object) {
return object.getName();
}


@Override
public void setValue(JsonData object, String value) {
//To change body of implemented methods use File | Settings | File Templates.
}


@Override
public String getPath() {
return null;
}
});
tree.setWidth(500);
tree.setHeight(400);
tree.getStyle().setLeafIcon(IconHelper.getImageResource(UriUtils.fromSafeConstant("images/folder/add.gif"), 12, 12));
tree.setCheckable(true);
tree.setCheckStyle(Tree.CheckCascade.TRI);
tree.setAutoLoad(true);


tree.addCheckChangedHandler(new CheckChangedEvent.CheckChangedHandler<JsonData>() {
@Override
public void onCheckChanged(CheckChangedEvent<JsonData> jsonDataCheckChangedEvent) {
Tree data=(Tree) jsonDataCheckChangedEvent.getSource();
StringBuffer b=new StringBuffer();
List<JsonData> l= data.getCheckedSelection();
if(null!=l&&!l.isEmpty()){
Iterator it=l.iterator();
while (it.hasNext()) {
b.append(((JsonData) it.next()).getName());
}
}
AlertMessageBox box=new AlertMessageBox("ee",b.toString());
box.show();


}
});
tree.setLoader(loader);


tree.setCheckStyle(Tree.CheckCascade.TRI);
tree.setCheckNodes(Tree.CheckNodes.BOTH);
return tree;
}


private void init() {
loader = createLoader();
FlowLayoutContainer con = new FlowLayoutContainer();


con.setWidth(500);
con.setHeight(400);
con.setTitle("tree");
con.setScrollMode(ScrollSupport.ScrollMode.AUTOY);
con.setStyleName("");
con.add(createTree(), new MarginData(10));
con.setBorders(true);
this.setHeadingText("permisson");
this.add(con);
this.setBodyBorder(true);
this.setMinimizable(true);
}
}


public interface JsonData{
public String getId();


public String getName();


public String getParent();
}


public class DataRecordJsonReader extends JsonReader<List<JsonData>, JSonDataRecordResult> {
public DataRecordJsonReader(AutoBeanFactory factory, Class<JSonDataRecordResult> rootBeanType) {
super(factory, rootBeanType);
}


@Override
protected List<JsonData> createReturnData(Object loadConfig, JSonDataRecordResult records) {
return records.getItems();
}

}


public interface JSonDataRecordResult {
public List<JsonData> getItems();
}
public interface JsonTreeAutoBeanFactory extends AutoBeanFactory {
AutoBean<JSonDataRecordResult> items();
}
public class KeyProvider implements ModelKeyProvider<JsonData> {
@Override
public String getKey(JsonData item) {
return item.getId().toString();
}
}




and the servers code like this:


public void list() throws JSONException {
Set<PermissionClsParent> l = permissionClsParentService.queryList(null, null, null);
JSONObject root = new JSONObject();
JSONArray array = new JSONArray();
if (null != l && !l.isEmpty()) {
Iterator<PermissionClsParent> it = l.iterator();
while (it.hasNext()) {
JSONObject oJson = new JSONObject();
PermissionClsParent p = it.next();
oJson.put("id", p.getId().toString());
oJson.put("name", p.getClsName());
oJson.put("parent", "true");
array.put(oJson);
}
}
//this key name as the interface name
/*
public interface JSonDataRecordResult {
public List<JsonData> getItems();
}
*/
root.put("items", array);
printInf(root.toString());
//the printInf method print the string is :{"items":[{"id":"1","name":"permissionname","parent":"true"}]}
}

now the tree only show the parent node,can't show the children node, the format of data like :{"items":[{"id":"1","name":"permissionname","parent":"true"}]}
how to create the data to add to the children node.or need change the client code?
thank you for your help.