cancel
Showing results for 
Search instead for 
Did you mean: 

Approach Context node in code

Former Member
0 Kudos

Dear forumpeople,

At this moment I try to set an attribute with this code:

wdContext.currentContextElement().set...

But, how should I set an attribute which is set in a node?

We tried:

wdContext.current***Element().set*("");

But this is not working because of a NullPointerException.

Any ideas?

Regards,

Adri

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi ,

Node is like a collection. You have to first initialise it... create elements and them use it.

IPrivateView<viewname>.I<nodename>Element  e = wdContext.node<nodename>().create<nodename>Element();

wdcontext.node<nodename>().addElement(e);

.

You have to do this for every element u create.. and then use



wdcontext.node<nodename>().get<nodename>ElementAt(no of the element.. ).setXXX();

And please do search this forum for even elobarate answers.

Good luc..

Regards

Bharathwaj

Answers (6)

Answers (6)

former_member189631
Active Contributor
0 Kudos

Hi Adri,

  • If your Problem is solved, Please award points for useful answers.

Regards,

<b>Ramganesan K</b>

Former Member
0 Kudos

Tnkx for the replies, we aprreciated your help

sid_sunny
Contributor
0 Kudos

Hi Adri,

SDN way to say thanx is by awarding points. it encourages them to spend some time for your queries and its a good practice which we should follow.

Regards

Sid

Former Member
0 Kudos

Hi Adri,

Suppose u have a node customer & attribute name inside that,it will be.

wdContext.nodeCustomer().currentCustomerElement().setName();

regards

Sumit

former_member189631
Active Contributor
0 Kudos

Adi,

  • That code applicable for context attubutes not for context Node Attributes.

  • Follow this code,

Adding Values to Context Node:

<b><i>Syntax:</i></b>

IPrivate<View Name>View.I<Node>Element x = wdContext.node<node>().create<node>Element();

WdContext.node<Node>().addElement(x);

x.set<AttributeName>("Value");

<b><u>Example:</u></b>

for ( int i=0;i<=10;i++){

IPrivateBusinessGraphicsView.ITestElement x = wdContext.nodeTest().createTestElement();

wdContext.nodeTest().addElement(x);

x.setMyAttr("100"+i);

x.setMyAttr("2000"+i);

}

  • This must be solve your Problem

Regards,

<b>Ramganesan K</b>

Former Member
0 Kudos

Hi Adri,

If you want to set a value to attribute in the node then use the following code:

wdContext.node<nodename>.current<NodeElement>.set<attibute>("");

Regards,

Jhansi

Former Member
0 Kudos

Hi,

Make the cardinality for the node as 1..1.