cancel
Showing results for 
Search instead for 
Did you mean: 

setting value to a node attribute

Former Member
0 Kudos

Hi,

I am simple view.

Context of the view has a node "Data" :cardinality :0..n , Selection 0..1

Attribute of Node "Data" is "text".

I am trying to set a value to the text attribute in the wdDoInit() of the view Implementation

wdContext.CurrentDataElement.settext("abc");

During runtime i am getting Null pointer exception.

Please explain me whether before setting the value to the attribute do i need to create that attribute element or i need to changed the propertiese of node or anything else ?

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Set the cardinality and selection as 1..n, then execute..

if found useful give points..

Juhi

Former Member
0 Kudos

I got the solution and more understanding of node cardinality.

By changing the cardinality to 1..1 i was able to set value to the attribute of node.

abhijeet_mukkawar
Active Contributor
0 Kudos

Hi,

congrats!!!!!!!

other thing when you have cardinality 0.n then you first need to create its element and then need to set the value attribute of that element and finally you need to bind that element to node. like

IPrivateTestapplView.IDataElement tmpEle = wdContext.createDataElement();

tmpEle.setText("Name");

wdContext.nodeData().bind(tmpEle); //this is done because node has no way to

//understand that tmpEle belongs to it..

hope it clears doubt

regards

Former Member
0 Kudos

Thanks abhijeet for the explanation.

I was making the mistake of assiging a value to attribute of anode with cardinality 0..n.

Now it is clear.

abhijeet_mukkawar
Active Contributor
0 Kudos

HI,

you are getting null pointer exception because the node data has no element , do one thing change its cardinality from 0.n to 1.n and try same statement.

it wont give error coz it has default element this time.

cardinality when set to 1.1. or 1.n means that the node will have default element at runtime which then can be refered . in case of 0.n , you first need to create the and then can set its values

hope it helps

regards

let me kno if you want something more elaboration