Development tools : XUI editor : Editing an XUI page : Editing the properties of the XUI widgets : Binding data to the XUI widgets : Binding data to widgets : Binding data to a tree widget
  
Binding data to a tree widget
This section provides an example of how to bind data to a tree widget.
To bind data to a tree widget
1 Define data structure. Make sure there is “treeModel” definition in btt.xml between <kColl id="classTable"></KColl> in data section.
<field id="treeModel"
value="com.ibm.btt.dojo.model.TreeModel"
description="A treeModel is used and only used to present tree item including label, value, etc, should not be used as generic collection." />
Then you need to define the tree structure model and submit data in operation or flow transaction. For example: add a treeModel type data Tree1RootModel as dataName for Tree content, add a simple filed data Tree1SubmitData as submit dataName for Tree.
This graphic is described in the surrounding text.
Make sure you also define value for label and value for treeModel Tree1RootModel:
This graphic is described in the surrounding text.
After you define treeModel, you need to initialize the treeModel in operation. For example:
public class InitContextOp extends BTTServerOperation {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*/
public void execute() throws Exception {
TreeModel root = (TreeModel) getElementAt("Tree1RootModel");
TreeModel level1_1 = new TreeModel("level1-1", "002", "%nls.bttsample/Level1");
TreeModel level2_1 = new TreeModel("level2-1", "005", "Level2");
level1_1.addChild(level2_1);

TreeModel level1_2 = new TreeModel("level1-2", "003", "Level1");
TreeModel level2_2 = new TreeModel("level2-2", "006", "Level2");
level1_2.addChild(level2_2);

TreeModel level1_3 = new TreeModel("level1-3", "004", "Level1");
TreeModel level2_3 = new TreeModel("level2-3", "007", "%nls.bttsample/Level2");
level1_3.addChild(level2_3);

root.addChild(level1_1);
root.addChild(level1_2);
root.addChild(level1_3);

this.fireExitEvent("ok");

}
}
2 Specify properties for tree widget.
In properties view, You need to specify Tree1SubmitData as dataName and Tree1RootModel as dataNameForTreeContent.
This graphic is described in the surrounding text.
Result
Data is bound to the tree widget.
Go up to
Binding data to widgets