cancel
Showing results for 
Search instead for 
Did you mean: 

Setting ValueSet for non singleton node causes NullPointerException

Former Member
0 Kudos

Hi,

Important: Please do read the question carefully and only answer if you are sure to know the answer. Please don't get me wrong, but I'm generally getting answers which are not very helpful !!!

For all those who are not scared off my first statement :

I'm generally setting ValueSets by using the following code:


IWDNodeInfo nodeInfo = wdContext.nodeExample().getNodeInfo();
ISimpleTypeModifiable modifiableSimpleType = nodeInfo.getAttribute(IExampleElement.NAME).getModifiableSimpleType();
IModifiableSimpleValueSet valueSet = modifiableSimpleType.getSVServices().getModifiableSimpleValueSet();
valueSet.put ...

This code works fine if the used node is Singleton.

In my case the node has to be Non Singleton AND it is possible that there is no element of this node when the above mentioned code is called. Therefore I'm getting a NullPointerException because wdContext.nodeExample() returns Null.

Is there a way to set the ValueSet in such a case? I'm currently fire an event when a new element is added to the node and call the ValueSet creation in the corresponding event handler. But this a more a workaround and I'm seeking for a proper solution.

Thanks in advance for your help and kind regards,

Marc

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

You should access the node via its parent element like


I<ParentNode>Element e = ...;
IWDNodeInfo info = e.nodeExample().getNodeInfo();

Armin

Former Member
0 Kudos

Hi Armin,

thank you for your answer. This solved my problem.

But to be honest, I don't really understand why wdContext.nodeExample() returns null while parentNodeElement.nodeExample() returns a reference to the desired node. I set the parentNodeElement to the element with the lead selection (=current element) so I don't really see the difference because according to the documentation wdContext.nodeExample() should return the descendant node Example that is on lead selection patch. So wdContext.nodeExample() and parentNodeElement.nodeExample() should be the same.

Could you please explain me the difference!

Kind regards,

Marc

Former Member
0 Kudos

Hi,

The singleton property can be defined for all dependent context nodes. It is either true or false:

singleton = true:* Newly defined context nodes are of type singleton by default. This means that a child node instances exists for each parent node, not for each node element in the parent node. The content of the child node, that is, the list of the node elements it contains, changes each time the lead selection of the parent node changes.

· singleton = false: A child node instance exists for each node element in the parent node. The content of this node instance does not change. The node instances of the child node can be accessed using generated context interfaces.

Non-singleton nodes always refer to a node element of the parent node at runtime.

Refer to the following link for more information.

http://help.sap.com/saphelp_nw70/helpdata/EN/81/95384162316532e10000000a1550b0/frameset.htm

Thanks & Regards,

Jhansi Miryala

Former Member
0 Kudos

Hi,

Have you tried with supply functions?

Regards

Ayyapparaj

Former Member
0 Kudos

Hi,

since I'm using model nodes I can't add a supplyFunction without loosing the corresponding supplyingRelationRole.

Kind regards,

Marc