Skip to Content
Former Member
Jan 16, 2004 at 04:02 PM

Dynamic recursive tree



I'm currently programming a Web Dynpro application that uses a dynamically

populated tree control. At the beginning the tree has only one child node (root).

When clicking on this node the child nodes for this node are created dynamically.

When clicking on the newly created child nodes, there will be nodes inserted

as child of these nodes (and so on).

While in my application the needed information for creating the new child nodes

is retrieved from SAP R/3 via BAPIs, in the demo application I insert always five

child nodes (labeled "Dyn node 0-4").

Here is a short description of my demo application:


ValueNode (RecTree)

- ValueAttr (text)

- RecNode (RecChild)


IRecTreeElement first = wdContext.createRecTreeElement();



onActionNodeClick(): // EventHandler called when clicked on a node

// get the currently selected node

IRecTreeElement current = null;

for (current = wdContext.currentRecTreeElement();

current.currentRecChildElement() != null;

current = current.currentRecChildElement());

IRecTreeNode curNode = current.nodeRecChild();

for(int i=0; i<5; ++i)


IRecTreeElement dynElem = curNode.createRecTreeElement();

dynElem.setText("Dyn node " + i);



By clicking on a node (to fill in new childs), expanding it, clicking on one

of the newly created childs, expanding it, ... I'm able to create only two

new levels of child nodes. What do I have to do if I need more levels of

dynamically created child nodes?

When population the tree in the wdDoInit()-method there is no such

limitation for the depth of the tree, but I need to do this part dynamically ;-(.

I hope there is a solution for this problem...

Best regards