cancel
Showing results for 
Search instead for 
Did you mean: 

NullPointerException in Merged Value Node

detlev_beutner
Active Contributor
0 Kudos

Hi there,

I have a component with it's component controller and a CustomController, lets call it CustCont. Within the context of the CustCont, there are two Value Nodes, lets call them GenericNode and SpecificNode, with different attributes (most of type string), lets call them genAtt1, genAtt2, specAtt1, specAtt2.

Now I have a view, lets call it V, with a context with a Value Node VN with context mapping in that kind, that all attributes of the SpecificNode and all attributes of the GenericNode are mapped (first map attributes to GenericNode, then to SpecificNode).

When I produce test values within the views implementation, wdDoInit, in the following form:

IPrivateV.IVNElement vn = wdContext.nodeVN().createVNElement;

vn.setGenAtt1("test");

vn.setGenAtt2("test");

vn.setSpecAtt1("test");

vn.setSpecAtt2("test");

the first or(!) the third set...() method leads to a NullPointerException, complete StackTrace below. It depends whether the VN is mapped to SpecificNode or to GenericNode (if to SpecificNode, then vn.setGenAtt1("test") throws the exception).

Somehow I understand that it may be problematic to map the attributes of VN to the attributes of different value nodes of the custom controller context (both have the same settings, so in my opinion, this could work).

What is really estonishing for me is that such a construction works if I do not set directly the attribute value of the node that is not mapped but map the attribute to the value of an InputField. Then I can type in some data and all the mapping work!

Any help?

Thanks in advance

Detlev

-


java.lang.NullPointerException

at com.sap.tc.webdynpro.progmodel.context.Paths.createAttributePointer(Paths.java:129)

at com.sap.tc.webdynpro.progmodel.context.MappedAttribute.getDataPointer(MappedAttribute.java:62)

at com.sap.tc.webdynpro.progmodel.context.MappedAttribute.setString(MappedAttribute.java:121)

at com.test.wdp.InternalChangeFilesystemRolesView$RoleElement.setRemark(InternalChangeFilesystemRolesView.java:383)

at com.test.V.wdDoInit(V.java:107)

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Detlev,

i tried to reproduce the problem with the following results, playing around with the cardinalities. GN is the generic node in the custom controller (attributes gt1, gt2), SN the specific node (attr. st1, st2), VN the merged and mapped node in the view V (attr. gt1..st2).

<b>1. GN: 1..1, SN: 1..1 -> VN: 1..1 OK</b>

<b>2. GN: 1..n, SN: 1..n -> VN: 1..n OK</b>

<b>3. GN: 0..n, SN: 0..n -> VN: 0..n, create Element VN in V wdDoInit() and bind before setting values:</b>

com.sap.tc.webdynpro.progmodel.context.ContextException: NodeInfo(CTView.VN): cannot modify gt1 because it is mapped and there is no active NodeElement to take the value

at com.sap.tc.webdynpro.progmodel.context.MappedAttribute.getDataPointer(MappedAttribute.java:65)

at com.sap.tc.webdynpro.progmodel.context.MappedAttribute.setString(MappedAttribute.java:121)

at de.ascoit.context.test.wdp.InternalCTView$VNElement.setGt1(InternalCTView.java:218)

at de.ascoit.context.test.CTView.wdDoInit(CTView.java:98)

<b>4. GN: 0..n, SN: 0..n -> VN: 0..n, create Element VN in V wdDoInit() and try to bind after setting values:</b>

java.lang.NullPointerException

at com.sap.tc.webdynpro.progmodel.context.Paths.createAttributePointer(Paths.java:129)

at com.sap.tc.webdynpro.progmodel.context.MappedAttribute.getDataPointer(MappedAttribute.java:62)

at com.sap.tc.webdynpro.progmodel.context.MappedAttribute.setString(MappedAttribute.java:121)

at de.ascoit.context.test.wdp.InternalCTView$VNElement.setGt1(InternalCTView.java:218)

at de.ascoit.context.test.CTView.wdDoInit(CTView.java:97)

<b>5. GN: 0..n, SN: 0..n -> VN: 0..n, create Elements of GN and SN and bind them in CUST wdDoInit(): OK.</b>

From my point of view, this is a bug in the toolset. It should be forbidden to map VN to GN (or SN) first, followed by changing the mapping of VN to SN (or GN) without declaring the mapping of the attributes of step 1 invalid, because:

If VN is mapped to GN first followed by mapping VN to SN, the attributes gt1/2 are children of a parent node, which is not mapped to the corresponding parent node of the data sink GN, which results in a validation error normally.

Best regards

Stefan