cancel
Showing results for 
Search instead for 
Did you mean: 

problem in accessing: Parentnode 0..n-->childnode 0..1-->subchild node0..1

Former Member
0 Kudos

Hi,

I have a problem in accessing the node3a's current element. Following is the context structure (which I am getting from backend BAPI).

Node1 is the parent node, it has 3 child nodes, and further Node2c has 3 child node. I need to access current elements of node 3a and display them in a form.

Node1 0..n singleton-true

-


Node2a 0..n singleton-true

-


Node2b 0..n singleton-true

--- Node2c 0..1 singleton-true

-


node3a 0..1 singleton-true

-


node3b 0..n singleton-true

-


node3c 0..n singleton-true

I have written the following code to access but its giving no output, i tried priniting size and i am getting the size as 1 that means there is data.

wdContext.node2c().node3a().getElementAt(0).getAttributeValue("Meins");

if atleast i get this one element "Meins", i can put a loop and access all other elemets, but no luck.

i also tried:

wdContext.node2c().node3a().current3aElement().getMeins(); but still no luck.

Can you please help me in this as i m really stuck and needs to b resolved urgently.

Thanks & Regards,

JJ

Accepted Solutions (0)

Answers (4)

Answers (4)

gill367
Active Contributor
0 Kudos

Hello Joshi,

Could tell me the code that you are using for checking the size of the node 3a and also could you please check the cardinality and selection property for the node.

Thanks

Sarbjeet Singh

Former Member
0 Kudos

Hi Joshi,

Firstly, you need to understand the use of cardinality and singleton.

Cardinality is the no. of elements that a node can hold. So in case you need a node to hold more than one element then you can set it to 0..n otherwise to 0..1

Singleton property if set to false let the node contain multiple elements otherwise not.

In order to access node 3a's elements, make the node's singleton as false and cardinality as 0..n

Now use the code

wdContext.node2c().node3a().get3aElementAt(int index).get<attribute>();

Regards,

Tushar Sinha

Former Member
0 Kudos

wdContext.currentNode3aElement().get<AttributeName>();

Armin

Former Member
0 Kudos

Hi Friend,

Try This Its Working My Side.


wdContext.nodeNode1().nodeNode2c().nodeNode3a().getCurrentElement().getAttributeAsText("Attribute1");

Here Attribute1 is the value attribute in your case Meins i Think. Let Us know if you need any more help in this.

Regards

Jeetendra

Former Member
0 Kudos

Hi All,

Thanks for ur inputs, now I am able to access 3a, using the suggested code.

But now the problem is that I am not able to access node 3b at the same time as my node 2 has cardinality 0..1

plz suggest any inputs.

Regards,

JJ.

Former Member
0 Kudos

Hi friend,

I want to know one thing while on loading( or execution of service ) are you sure that values are coming in all node.

if cardinality is 0-n means it can have 0 or n numbers of elements in it. and even if there is one single element is there then you can access it otherwise it will throw null pointer exception. if there is some value in 3b then you can access it by.


wdContext.nodeNode1().nodeNode2c().nodeNode3b().getCurrentElement().getAttributeAsText("Attribute1");

Check it and let us know if any issue persist.

Regards

Jeetendra