cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic context - Creation and Model binding

Former Member
0 Kudos

Hi, I would like to know if it is possible to do the following and how to do it:

1- Create a new attribute for a context node that is not defined at design time;

2- Create a new node that is not defined at design time;

3- Bind a model class to a node at runtime;

I searched for answers in this forum and the documentation but I did not find any complete information.

Thanks and regards,

Barthelemy

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

It is certainly possible.

Try the following code snippet:

IWDNodeInfo nodeInfo = wdContext.wdGetAPI().getRootNodeInfo().addChild("TestNode", null, true, true, false, true, false, true, null, null, null);

//If you want to bind the node to a model node then the

//second argument to the above method should be the

//model class

IWDAttributeInfo testAttrib = wdContext.wdGetAPI().getRootNodeInfo().getChild("TestNode").addAttribute("testAttrib", "ddic:com.sap.dictionary.string");

IWDNodeElement testNode = wdContext.getChildNode("TestNode", IWDNode.LEAD_SELECTION).getCurrentElement();

IWDNode testNode2 = wdContext.getChildNode("TestNode", IWDNode.LEAD_SELECTION);

//Now you can bind testNode with the Model Node

//You can also set a value to the newly created attribute

testNode.setAttributeValue("testAttrib", new String("Value"));

Hope this helps.

Shakeel