cancel
Showing results for 
Search instead for 
Did you mean: 

Creating Instances of a ValueNode at runtime

Former Member
0 Kudos

Hi

I Have a context value node say

RootNode (0..N)

-


>Valueattribute1(String)

-


>Valueattribute2(Integer)

At run time i want to create multiple instances of the rootnode and bind each instance of a rootnode to a table.

Table is also created at runtime. Number of instances that needs to be created depends on the back end.

Is there a way where i can create multiple instances of the context node created at design time? If possible please provide code sample.

Present solution i have is creating the context node at run time for each table i create.

Is there any other way where i can solve this.

Appreciate the response.

Regards

Naga Kishore

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi NagaKishore,

you can't have several instances of the same node. But what you can do is create dynamically the number of nodes that you need and call them RootNode0, RootNode1,... RootNode<n>, and then bind each of these nodes to a table (you can create dynamically UI elements only in method wdDoModifyView()).

Best Regards,

Julien

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

Technically, instances of the node we create can hold one collection of data..

To store different collections of data using the same node is not possible.

We can either create three nodes of the simialr type.. or create a structure at design tiime.. use that to create three nodes at runtime..create instance of it and bind it to 3 different tables..

Regards

Bharathwaj

monalisa_biswal
Contributor
0 Kudos

I think u can solve it using Recursive Tree.

add elements to ur context node

depending on number of tables u need to have.

Then to bind ur table to the node

take child recursive node's instance for each of these elements . To populate ur table add elements to these recursive child node instances.

Former Member
0 Kudos

Hi,

You cannot create multiple instances of context node, it will give an error:

com.sap.tc.webdynpro.progmodel.context.ContextException: Node(<View_Name>): must not add elements to a Node of cardinality 0..1 or 1..1

Nodes created under context can have mutiple instances, that can created in runtime.



IPrivate<View_Name>.I<Node_Name>Node Node =
wdContext.node<Node_Name>();

IPrivate<View_Name>.I<Node_Name>Element Element;

Element = Node.createFolderContentElement();
Element.setName("");
Element.setInteger(5);
Node.addElement(Element);

with regards,

Mahesh

Please award points if the answer is usefull.

Former Member
0 Kudos

Hi Nagakishore,

If I am not wrong, you have created node hierarchy at design time. You just want to create elements at runtime, right?

That is easy. Use following code for the same.

IPrivate<view name>.I<nodename>Element ele = wdcontext.create<node name>Element();

ele.set<attribute>(<value>);

wdcontext.node<node name>().addElement(ele);

It will add one element in the node.

Write this code inside loop and create as much elements as you wish at runtime.

Regards,

Bhavik