Showing results for 
Search instead for 
Did you mean: 

Dynamic recursive tree

0 Kudos


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


Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Thomas,

I guess you have already seen the post within this forum "Use Tree  Recursive in web dynpro" where I described the demo application...

Need to talk to the developers!

Best regards, Karin

Former Member
0 Kudos

Hi Karin,

you are totally right - I did see this coding example, but it doesn't

help in my case.

Like I described, all works perfectly fine when filling the tree

in "wdDoInit()", but filling the tree elsewhere is limited to two new

levels of child nodes...

Hope there will soon be a solution.

By the way, did you get my e-mail?

Best regards, Thomas  

Former Member
0 Kudos

Hello Thomas,

Unfortunately I did not get your e-mail. Could you please send it again to the following address:

Regarding your issue, I will talk to the developers and will come back to you asap.

Best regards, have a nice weekend,


Former Member
0 Kudos

Hi Karin,

I just resend the e-mail.

Thanks for your efforts.

Best regards, enjoy the lovely weather,


Former Member
0 Kudos

Hi Thomas,

Thank you! I have seen your e-mail. Please give me a couple of days to response!

Regarding the post:

We just rebuild the project you described and it works perfectly fine with the current version of Web Dynpro. I can easily load data for several levels; I'm not limited to 2 new levels. So it seems that your version of Web Dynpro still contains a bug that caused the lead selection to be set incorrectly when clicked on a node - causing your program logic to return the wrong current TreeElement. I'm afraid there is no work-around within your version. Sorry for the inconvenience...

'The next Sneak Preview version should solve this issue...

Best regards, Karin

Former Member
0 Kudos

Hi Karin,

should have guessed that it might be another version problem...

But I think it has nothing to do with the lead selection:

After navigation through the tree to the currently selected

node, I displayed the statistics of this node in another area.

Therefore I can say that it was the correct node I tried to

add the new childs to. When adding the new child nodes to

this node, there was no effect (and no exception either).

Nevertheless I wish to thank you for your reconstruction

of the problem with the current version.

Best regards, Thomas

Former Member
0 Kudos

Hi Thomas,

Sorry for this. I really think, the next preview will solve this issue!