cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a new Node and bind it to the wdContext root at run time

Former Member
0 Kudos

Hi experts,

Does anyone have sample code about 1) adding a new node to the root context, 2) give it a name and 3) referring to this newly created node with the conetxt path?

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

btw, could you provide the link for the javadoc?

Answers (5)

Answers (5)

Former Member
0 Kudos

Armin,

I am trying to do this and keep getting erro about incompatible class:

wdContext.getNodeInfo().addChild("DynamicNode",

mymodel.class,

true,

CMICardinality.ONE,

CMICardinality.ZERO_TO_ONE,

true,

wdContext.getContext().getStructure("com.my.structure") );

IWDNode node = wdContext.getChildNode("DynamicNode", 0);

IWDNodeElement e = node.createElement(an_instance_of mymodelObject());

node.addElement(e);

Can I do it this way?

Former Member
0 Kudos

If I have an existing object, say an instance of a "User" class. Can I just bind this instance to this node?

Thanks for providing the links.

Former Member
0 Kudos

The code given creates a value node. You can create and add elements to this node and set their attribute values.


IWDNode node = wdContext.getChildNode("DynamicNode", 0);
IWDNodeElement e = node.createAndAddElement();
e.setAttributeValue("attributeName", value);

Armin

Former Member
0 Kudos

So I can bind this node to any object at run time?

Thanks again Armin.

Former Member
0 Kudos

I don't understand this question.

Armin

Former Member
0 Kudos

Thanks Armin,

Do I need to specify the class when creating this new node?

addChild("DynamicNode",

null, // CLASS NAME

true,

CMICardinality.ONE, /* at least one and not multiple = 1:1 */

CMICardinality.ZERO_TO_ONE, /* no lower bound and not multiple = 0:1 */

true, null);

If it is added to the root, can I then refer it using the context path as "DynamicNode" just like those nodes created at design time?

Thanks again.

Former Member
0 Kudos

No, the class argument may be NULL, please read the Javadoc.

Yes you can refer to this (top-level) node using the node name.

Armin

Former Member
0 Kudos

Call this method on wdContext.getNodeInfo().

Armin