cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing context node and attributes

Former Member
0 Kudos

Hi,

Who knows to access and create the following context properly?

I have the following context:

Table 1..1

TableList 1..1

TableWrapper 0..n

Data 0..1

- name

- age

How to add the name and age to a newly created TableWrapper via Data Node?

IWrapperElement elWr = wdContext.nodeTableWrapper().createTableWrapperElement();

and then how to access data node properly??

Kind regards,

Sandhya

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Table 1..1

TableList 1..1

TableWrapper 0..n

Data 0..1

- name

- age

If your context structure is as shown above

Table and TableList is having cardinality 1..1 so you dont have to create one explicitly.

TableWrapper needed to be created as its 0..n

Following code is used to create one element of table wrapper

ITableWrapperElement element = wdContext.nodeTableWrapper().createAndAddTableWrapperElement();

Now for the element of TableWrapper create a element for the datanode

wdContext.nodeTableWrapper().setLeadSelection(element.index());

IDataElement dataElement = wdContext.nodeTableWrapper().nodeData().createAndAddDataElement();

hope its clear

Regards

Ayyapparaj

Former Member
0 Kudos

I found the solution.

for(int i = 0; i < k ; i++) {

ITableWrapperElement elWr =wdContext.nodetableList().nodeTableWrapper().createTableWrapperElement();

wdContext.nodeTableWrapper().addElement(elWr);

IDataElement dataEl = elWr.nodeData().createNodeDataElement();

dataEl.setAge("23");

dataEl.setname("Santino");

elWr.nodeData().bind(dataEl);

}

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

IDataNodeElement ele= wdContext.nodeDataNode().currentDataNodeElement();

if(ele!=null){

ele.getName();

ele.getAge();

}

Former Member
0 Kudos

Hi,

Table Node contains TableList Node.

TableList Noed contains TableWrappers Node.

TableWrapper Node contains the Data Node.

Data Node contains the attributes age and name.

Something went wrong, but this is the structure.

Sandhya

Former Member
0 Kudos

Hi,

Table Node contains TableList Node.

TableList Noed contains TableWrappers Node.

TableWrapper Node contains the Data Node.

Data Node contains the attributes age and name.

IWDNodeElement nodeElement = wdContext.nodeTableWrapper.createAndAddElement();

IWDNodeElement datanodeElement = nodeElement.createAndAddDataNodeElement();

datanodeElement.setAttribute("<attributeName>","<value>");

datanodeElement.setAttribute("name","AAA");

datanodeElement.setAttribute("age","1");

Regards

Ayyapparaj

Former Member
0 Kudos

Can you please explain it in more detail?