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.
Make sure you also define value for label and value for treeModel Tree1RootModel:
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);