cancel
Showing results for 
Search instead for 
Did you mean: 

Null pointer Exception while setting a value

Former Member
0 Kudos

Hi,

Im trying to move the contents of a model node into a Value node. But I am getting a null pointer exception.

Here is my structure

Source node:

<Model Node>

-


<Output Node>

-


<Li Node> (li_Shipper)

-


<Model Attribute>

Destination node

<Model Node>

-


<Output Node>

-


<Li Node> (li_Allocations)

-


<Value Node> (Shipper_DD) 0..1 singleton-false

-


<Value Attribute> (Shipper)

My code is as follows:

for (int i=0; i<wdContext.nodeLi_Allocations().size();i++)

{

WDCopyService.copyElements(wdContext.nodeLi_Shipper(),wdContext.nodeLi_Allocations().getLi_AllocationsElementAt(i).nodeShipper_DD());

// Here im trying to assign a default value. Im getting the null pointer exception in this line.

wdContext.nodeLi_Allocations().getLi_AllocationsElementAt(i).nodeShipper_DD().currentShipper_DDElement().setShipper(wdContext.nodeLi_Allocations().getLi_AllocationsElementAt(i).getShipper());

}

Can anyone tell me how I can rectify this?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Reena,

Set the cardinality of the <Value Node> (Shipper_DD) to 1:1.

Bala

Former Member
0 Kudos

Hi Reena,

You need to first bind the model object vairables in the wdDoInit() method of the controller.

And after you have done that you can set the values like this:

IPrivate<View>.I<Node>Element ele= wdcontext.createnodeCElement();

ele.setItem1(<value>);

wdcontext.nodeC.addElement(ele);

Please try to create an element under the node. Please check the code for syntax. I hope this should solve your problem.

Thanks & Regards

--Vishal Sood

<b>PS: Please provide points for helpful answers</b>

Former Member
0 Kudos

Hi

Thanks a lot.

The problem is solved.

Thanks and Regards,

Reena

Answers (1)

Answers (1)

Yashpal
Active Contributor
0 Kudos

Hi Reena,

have u created the instance of value node u r using........if no create it and then try.......

Regards,

Yash