Skip to Content
author's profile photo
Former Member

Dynamic context - Creation and Model binding

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

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • author's profile photo
    Former Member
    Jun 14, 2004 at 11:01 PM

    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

    Add comment
    10|10000 characters needed characters exceeded