zakabog
11-26-2008, 01:56 PM
I'm trying to figure out how to set a TreeItem's ID. I create the tree and fill it with BaseTreeModels (it's the only way I've found for populating a tree.) I can set the text of the item but I can't figure out how to set the ID. Below is the code I have to create the items, as you can see I tried
companyFolder.set("id", companyID);thinking that might do it but it doesn't work.
if (companies != null) {
for(int i = 0; i < companies.getLength(); i++) {
if (companies.item(i).toString() != null) {
Node companyNode = companies.item(i);
Element company = (Element) companyNode;
String companyID = company.getElementsByTagName("companyid").item(0).getChildNodes().item(0).getNodeValue();
String companyName = company.getElementsByTagName("name").item(0).getChildNodes().item(0).getNodeValue();
if (companyName != null) {
BaseTreeModel companyFolder = new BaseTreeModel();
companyFolder.set("name", companyName);
companyFolder.set("id", companyID);
String[] subFolders = {"Moderators", "Users", "Conferences"};
NavTree.store.add(companyFolder, false);
for (int j = 0; j < subFolders.length; j++) {
BaseTreeModel subFolder = new BaseTreeModel();
subFolder.set("name", subFolders[j]);
NavTree.store.add(companyFolder, subFolder, false);
}
}
}
}
}
companyFolder.set("id", companyID);thinking that might do it but it doesn't work.
if (companies != null) {
for(int i = 0; i < companies.getLength(); i++) {
if (companies.item(i).toString() != null) {
Node companyNode = companies.item(i);
Element company = (Element) companyNode;
String companyID = company.getElementsByTagName("companyid").item(0).getChildNodes().item(0).getNodeValue();
String companyName = company.getElementsByTagName("name").item(0).getChildNodes().item(0).getNodeValue();
if (companyName != null) {
BaseTreeModel companyFolder = new BaseTreeModel();
companyFolder.set("name", companyName);
companyFolder.set("id", companyID);
String[] subFolders = {"Moderators", "Users", "Conferences"};
NavTree.store.add(companyFolder, false);
for (int j = 0; j < subFolders.length; j++) {
BaseTreeModel subFolder = new BaseTreeModel();
subFolder.set("name", subFolders[j]);
NavTree.store.add(companyFolder, subFolder, false);
}
}
}
}
}