cancel
Showing results for 
Search instead for 
Did you mean: 

Context Node ( set values but looks like its overwritten ) ?

Former Member
0 Kudos

Hello Friends,

Actually what I need is storing some values in one method and then access them on one particular action. so as context-node are like collection, I thought to make a context-node lets say ZchkQty with two values Ztitle and ZaviabQty. ( cardinality of node is 1..n )

So I store the values like:

wdContext.currentZchkQtyElement().setZtitle(wdContext.currentZmat_FgElement().getTitle());

wdContext.currentZchkQtyElement().setZaviabQty(wdContext.currentZmat_FgElement().getZverfuegbst());

Then I want to access them like followings:

I checked the size and its 1, and actually it should be in my test case atleast 2:

wdContext.nodeZchkQty().size();

When I check this : wdContext.nodeZchkQty().getZchkQtyElementAt(i).getZtitle() then this contains the 2nd and last title, not the first one ?

I guss I am overwritting in the context node, what is the right way to store values in the context node ?

Regards,

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member751941
Active Contributor
0 Kudos

Hi Shah,

Node cardinality is 1..n means only one element is created and you are setting the value to that element that’s why value is overwriting.

Make node cardinality 0..n and Try this.

IPrivateUserComponentView.IZchkQtyElement ZchkQtyElm1 = wdContext.createZchkQtyElement();

ZchkQtyElm1.setZtitle("xxxx");

ZchkQtyElm1.setZaviabQty("10");

wdContext.nodeZchkQty().addElement(ZchkQtyElm1);

IPrivateUserComponentView.IZchkQtyElement ZchkQtyElm2 = wdContext.createZchkQtyElement();

ZchkQtyElm2.setZtitle("yyyy");

ZchkQtyElm2.setZaviabQty("20");

wdContext.nodeZchkQty().addElement(ZchkQtyElm2);

Regards,

Mithu

Former Member
0 Kudos

Thanks for your response:

I do not understand why we need to create an element, ?

Can you pls guide me to some docu or so ?

Regards,

Former Member
0 Kudos

Hi Shah,

When u say current<xyz>Element, it takes the current selected element from the node & set the values to it.same is happening in ur case & its overwriting the same element. So in that case u need to create an element & add values to it. In that case it will create another element & ur value will be added to that element.then u can check the size & it will show size as 2

regards

Sumit

Former Member
0 Kudos

Hi Shah,

If ur doubt is clear & problem resolved.close the thread.

regards

Sumit

Former Member
0 Kudos

Hi sumit,

I have not tried this yet, hang around with other issues, .... but I am closing this thread...

Regards,

former_member197348
Active Contributor
0 Kudos

Hi Shah,

Create an element and add this to the value node.


IPrivate<Viewname>.I<nodeElement> ele = wdContext.create<nodeElement();
// Set the attributes
ele.setX();
//For each new element you need to add to node.
wdContext.node<Node>.addElement(ele);

For better understanding of this concept, you can use this tutorial

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/user-interface-tec...

Hope this is helpful for you.

regards,

Siva