cancel
Showing results for 
Search instead for 
Did you mean: 

How to set value to a node inside a node?

Former Member
0 Kudos

Hi all,

i have a context like this:

Order (0...n)

L---LineItem (0...n)

. . L----ProductNo

. . L----Quantity

L CustomerName

L Address

I have no problem setting values for the Order level, but how to set values for the LineItem level?

this is how i create the Order level.


IOrderElement ele = wdContext.nodeOrder.createOrderElement();
ele.setCustomerName("Bob");
ele.setAddres("Some address");
wdContext.nodeOrder.addElement(ele);

IOrderElement ele = wdContext.nodeOrder.createOrderElement();
ele.setCustomerName("John");
ele.setAddres("Some other address");
wdContext.nodeOrder.addElement(ele);

but when i try to create the LineItem level using the same way, they all add to the first element of the Order node.

how to add LineItem element to the correct element of the order element?

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

It depends. If the inner node is a non-singleton child node, then every element of the outer node has its own instance of the inner node and you can access this like


IOrderElement order = ...;
/* create and add line item to order: */
ILineItemElement item = order.nodeLineItem().createAndAddLineItemElement();
/* access all line items for order: */
for (int i = 0; i < order.nodeLineItem().size(); ++i)
{
  ILineItemElement item = order.nodeLineItem().getLineItemElementAt(i);
}

If the inner node is a singleton child node, it exists only for the lead selected element of the parent node. The current instance can then be accessed like


wdContext.currentOrderElement().nodeLineItem();

Armin

Former Member
0 Kudos

Hi Armin,

thanks for the reply, but there no such method for the IOrderElement class, i can't get acess to the instance. there's no ".nodeLineItem()"

ILineItemElement item = order.nodeLineItem().createAndAddLineItemElement();

i am using 7.1 CE, is that why?

Former Member
0 Kudos

That means the inner node "LineItem" is singleton, right? In that case, define a supply function for this node like


void supplyLineItem(ILineItemNode node, IWDNodeElement parentElement)
{
  IOrderElement order = (IOrderElement) parentElement;
  ILineItemElement item = node.createAndAddLineItemElement();
  // etc
}

Armin

Answers (0)