cancel
Showing results for 
Search instead for 
Did you mean: 

Setting Node Attributes for a non singleton node

Former Member
0 Kudos

HI,

I want to know what is the correct way to set attributes for a non singleton node dynamically.

I have node A which contains the non singleton node B.

At runtime I want to change the attributes of node B dynamically. What is the correct way for this?

When I try wdContext.nodeB().getNodeInfo I get a NullPointerException.

For example this code works: wdContext.nodeA().getAElementAt(0).nodeB().getNodeInfo(). Here I get the node info.

But when I set attributes for the second line, are there valid for all Elements in Node B?

What is the correct way to set the attribut infos for non singleton Node B?

Best regards,

Peter

Accepted Solutions (1)

Accepted Solutions (1)

siarhei_pisarenka3
Active Contributor
0 Kudos

Hi Peter

The main rule here - do not touch node instances at all. Deal only with node metadata:


IWDNodeInfo nodeBInfo = wdContext.getNodeInfo().getChild("node A").getChild("node B");
nodeBInfo.getAttribute("xAttr");
nodeBInfo.addAttribute(...);
...

BR, Siarhei

Edited by: Siarhei Pisarenka on Jan 13, 2010 12:55 PM

Former Member
0 Kudos

HI,

thanks, I didn't know that metadata can be handled in this way.

Thank you very much, you saved the day

Best regards,

Peter

Former Member
0 Kudos

For accessing attributes created at design-time it is preferable to use the generated constants I<Node>Element.ATTRIBUTE_NAME.

Armin

Former Member
0 Kudos

Hi Armin,

thanks for the information.

Best regards,

Peter

Answers (0)