cancel
Showing results for 
Search instead for 
Did you mean: 

node<myNode>.create<myNode>Element causes nullPointer exception

Former Member
0 Kudos

Hi experts,

I have a structure of node and childnodes in the context which I'd like to provide with data from a RFC. it is basicly a 4 level structure.

Structure ( 0..1)

--> Store (0...n)

-


> Headers(0...n)

-


> Lines (0...n)

what I do is I create the root node. then I create a collection of the child nodes and I bind this to the root node and this way my structure is created and filled with data top down. I think this is the best way?

this workes fine for Structure, Store and Headers. however when I arive at the level of Lines wdContext.nodeLines().createLinesElement() causes a NullPointer exception. I've used the same way for all the parent. and had no such problems. what am I overlooking? did anyone have the same issues?

Thanks in advance.

Alperen

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

The coding should be like:

1) Line node data existence depends on row existence of headers node

2) Same thing applies for parent-child nodes of tree

In your case null pointer exception while adding row through : wdContext.nodeLines().createLinesElement()

is because

nodeLines is itself not existing

To overcome this error,

a) create headers node element say headersElement

b) Use headers node element as reference for creating element for lines i.e.

LineElement el = headersElement.nodenodeLines().createLinesElement() ;

regards,

ganga

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

If except Structure (main node under root context), for all the remaining child nodes if the singleton property is false.

Then do you need to set the values like this.

lIPrivateTestNewView.IStructureElement structureElement=wdContext.createStructureElement();
structureElement.setStructureValue1("StructureValue1");
		
IPrivateTestNewView.IStoresElement storesElement=structureElement.nodeStores().createStoresElement();
storesElement.setStorreValue1("StoreValue1");
		
IPrivateTestNewView.IHeadersElement headersElement=storesElement.nodeHeaders().createHeadersElement();
headersElement.setHeaderValue1("HeaderValue1");
		
IPrivateTestNewView.ILinesElement linesElement=headersElement.nodeLines().createLinesElement();
linesElement.setLineValue1("LineValue1");

Regards,

Charan