cancel
Showing results for 
Search instead for 
Did you mean: 

how to handle node with in a node of component controler context

Former Member
0 Kudos

I want to create node within a node in the context of component controller. Now in the doInit method of the Component Controller I want to populate the node structure. How to do that? because in the parent node I can populate its attribute but there is no setter method for the child node , by which I can set the child to the parent node. can anybody help me ..

I have tried by using the setAttribute method of the parent to add the child. for that two parameter I have passed one are child node name and the other one is the child node object(populated one)

rgds,

Soumen

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Soumen,

When we create the node itself, we need to associate it with the parent node. The following lines of code will help you to create a node(singleton, 1..1 cardinality) under a parent node:

Assumptions for the following code are:

1) The name of the parent node is 'parent_node'.

2) The cardinality of 'parent_node' is 1..1 or 1..n. If you set the cardinality starting from zero, you need to explicitly create an element and then set the leadselection before using this code.

IWDNodeInfo NodeInfo = wdContext.nodeParent_node().getNodeInfo().addChild("child_node",null,true,true,false,false,false,true,null,null,null);

IWDAttributeInfo info = NodeInfo.addAttribute("child_Attribute" , "ddic:com.sap.dictionary.string");

wdContext.nodeParent_node().getChildNode("child_node",wdContext.nodeParent_node().getLeadSelection()).getCurrentElement().setAttributeValue("child_Attribute","Test Value");

wdComponentAPI.getMessageManager().reportSuccess(" The value set is ::"+wdContext.nodeParent_node().getChildNode("child_node",wdContext.nodeParent_node().getLeadSelection()).getCurrentElement().getAttributeValue("child_Attribute"));

Hope this helps,

Best Regards,

Nibu.

Former Member
0 Kudos

Is the child node a singleton or non-singleton?

Armin

Former Member
0 Kudos

Armin,

Child node is singleton.

..

soumen