cancel
Showing results for 
Search instead for 
Did you mean: 

WDTree Dyn Control

Former Member
0 Kudos
301

Hi,

I need to develop a dynamically growing tree control in WAS 6.3.

Is this possible WDTree Dyn Control ? If so, could anybody help on this ?

Also can I manually do the coding for inserting a WD control instead of using the control using the wizards. This is to understand the code pieces behind the dynpro technology.

Regards,

Sharafudheen

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Sharafudheen,

here's a little example for you which combines a tree created at designtime and a tree created at runtime in one TransparentContainer:

1. Create a View named "RecursiveTreeView"

2. In the View context define a Value Node "TreeNode" with a Value Attribute "text" and a Recursion Node "Child". It's important that you type these names correctly, since the Context paths will later be used for the data binding of the dynamic tree at runtime. The "repeatedNode" property of "Child" must be linked to its parent node "RecursiveTreeView.TreeNode".

3. Layout and Data-Binding:

Use "MatrixLayout" for the RootUIElementContainer.

Insert a Button with text "Create second dynamic tree" and onAction "CreateDynamicTree". Use "MatrixHeadData" for the "layoutData" property of the button.

Insert a TransparentContainer named "TreeContainer" with "GridLayout" and 2 columns. Use also "MatrixHeadData" for the "layoutData" property of the container.

Insert a tree (the static one) named "RecursiveTree" into the transparent container. Set the "dataSource" of the tree to "RecursiveTreeView.TreeNode" and the "rootText" to what you like.

Add a TreeNodeType child to the tree named "RecNode". The dataSource of the node is also "RecursiveTreeView.TreeNode", the text should be bound to "RecursiveTreeView.TreeNode.text".

4. Implementation. Insert the following code snippets into the Implementation of RecursiveTreeView (You can see where to insert looking at the @@begin tags):

//@@begin wdDoInit()

IPrivateRecursiveTreeView.ITreeNodeElement level1element;

for (int i = 0; i < 2; i++) {

level1element = wdContext.createTreeNodeElement();

level1element.setText("Node " + i);

wdContext.nodeTreeNode().addElement(level1element);

for (int j = 0; j < 4; j++) {

IPrivateRecursiveTreeView.ITreeNodeElement level2element = level1element.nodeChild().createTreeNodeElement();

level2element.setText("SubNode " + i + "." + j);

level1element.nodeChild().addElement(level2element);

for (int k = 0; k < 6; k++) {

IPrivateRecursiveTreeView.ITreeNodeElement level3element = level2element.nodeChild().createTreeNodeElement();

level3element.setText("SubNode " + i + "." + j + "." + k);

level2element.nodeChild().addElement(level3element);

}

}

}

//@@end

//@@begin wdDoModifyView

if (wdContext.currentContextElement().getCreateDynamicTree()) {

// Disable button to avoid second creation.

wdContext.currentContextElement().setCreateDynamicTree(false);

IWDButton createButton = (IWDButton) view.getElement("CreateTreeButton");

createButton.setEnabled(false);

// Create tree and node type and bind node to tree

IWDTree tree = (IWDTree) view.createElement(IWDTree.class, "DynRecursiveTree");

IWDTreeNodeType treeNode = (IWDTreeNodeType) view.createElement(IWDTreeNodeType.class, "DynRecursiveTreeNode");

tree.addNodeType(treeNode);

tree.bindDataSource("TreeNode");

tree.setRootText("Dynamic recursive tree");

// Layout like static one

IWDGridData treeLayoutData = (IWDGridData) tree.createLayoutData(IWDGridData.class);

treeLayoutData.setVAlign(WDCellVAlign.TOP);

treeLayoutData.setWidth("50%");

// Bind like static one

treeNode.bindDataSource("TreeNode");

treeNode.bindText("TreeNode.text");

// Add to right side of container.

IWDTransparentContainer container = (IWDTransparentContainer) view.getElement("TreeContainer");

container.addChild(tree);

}

//@@end

//@@begin onActionCreateDynamicTree(ServerEvent)

// Set flag to create tree on the next wdDoModifyView hook.

wdContext.currentContextElement().setCreateDynamicTree(true);

//@@end

5. Build and deploy. If i didn't miss something, you should see the button and static tree. Clicking the button creates the dynamic tree, which shares the same context than the static one and disables the button. Congratulations, you created your first dynamic tree at runtime.

Bye

Stefan

Former Member
0 Kudos

Hi Sharafudheen,

i missed one point in the previous post:

There should also be added a boolean Value Attribute "CreateDynamicTree" on the root level of the View Context.

Bye

Stefan

Former Member
0 Kudos

Hello Sharafudheen,

we will introduce an enhanced documentation on Dynamic Programming with Web Dynpro via SDN or via a new version of the Sneak Preview edition (where this topic will be included in the help) in a couple of weeks. Please stay tuned!

You can use dynamic controls within Web Dynpro. You also could do manual coding - but restrictions apply in order to allow synchronisation with the visual model. You will have more details on this once we have completed and released the documentation.

Greetings

Ivo