PDA

View Full Version : TreeLoader Problem - Not showing/display tree data



sufiya
27 Nov 2009, 5:54 AM
Hi

It looks like tree is rendered but i am unable to see data any help?

-My code snippet -
My main Class goes here:



public class GroupTree extends LayoutContainer {
TreePanel<ModelData> tree;
TreeStore<ModelData> store = new TreeStore<ModelData>();
public GroupTree() {
super();
tree = new TreePanel<ModelData>(store);
}
@Override
protected void onRender(Element parent, int pos) {
super.onRender(parent, pos);

setLayout(new FlowLayout(10));
final GroupServiceAsync groupService = GWT.create(GroupService.class);
String webAppBaseURL = GWT.getModuleBaseURL().substring(0, GWT.getModuleBaseURL().indexOf(GWT.getModuleName()));
((ZAPIServiceProxy) groupService).setURL(webAppBaseURL + "apis/XMLrequest");
((ZAPIServiceProxy) groupService).setUser("root");
((ZAPIServiceProxy) groupService).setPassword("engsup123");

final RpcProxy<List<GroupInfoCustom>> proxy = new RpcProxy<List<GroupInfoCustom>>() {
protected void load(Object loadConfig, final AsyncCallback<List<GroupInfoCustom>> callback) {
GroupListIterStart gpList = new GroupListIterStart();
gpList.setListSubgroups(true);
groupService.groupListIterStart(gpList, new AsyncCallback<GroupListIterStartResult>() {
public void onFailure(Throwable caught) {
MessageBox.info("Failure", caught.getMessage(), null);
}
public void onSuccess(GroupListIterStartResult result) {
if (result != null) {
GroupListIterNext gpNextList = new GroupListIterNext();
gpNextList.setTag(result.getTag());
gpNextList.setMaximum(result.getRecords());
groupService.groupListIterNext(gpNextList, new AsyncCallback<GroupListIterNextResult>() {
public void onFailure(Throwable caught) {
//To change body of implemented methods use File | Settings | File Templates.
}
public void onSuccess(GroupListIterNextResult nextResult) {
if (nextResult != null) {
List<GroupInfo> groups = nextResult.getGroupList();
BeanModelFactory factory = BeanModelLookup.get().getFactory(groups.get(0).getClass());
List<ModelData> groupModel = new ArrayList<ModelData>();
for (GroupInfo group : groups) {

GroupInfoCustom groupInfoCustom = new GroupInfoCustom();
System.out.println("ID-->" + group.getId() + "--->" + group.getName());//data shown properly
groupInfoCustom.setId(group.getId());
groupInfoCustom.setName(group.getName());
store.add(groupInfoCustom, true);

}
tree.setDisplayProperty("name");
tree.getStore();
tree.setStyleAttribute("border", "1px solid red");
tree.setBorders(true);
}
}
});
}
}

});

}
};
ContentPanel cp = new ContentPanel();
cp.setHeading("Tree");
cp.setLayout(new FitLayout());
tree.getStore().getAllItems();
cp.add(tree);
cp.setSize(315, 400);
BaseTreeLoader<ModelData> loader = new BaseTreeLoader<ModelData>(proxy);
loader.load();
add(cp);
}

}


GroupInfoCustom getter and setter goes here:


public class GroupInfoCustom extends BaseModelData {


public void setId(Integer id) {
set("id",id);
}

public Integer getId() {
return get("id");
}

public void setName(String name) {
set("name",name);
}

public String getName() {
return get("name");
}

}


Am i missing anything here i am able to see the color change on move nodes but unable o see any data in tree.

thanks in advance