cancel
Showing results for 
Search instead for 
Did you mean: 

Getting several dynamic tables from one context

former_member182374
Active Contributor
0 Kudos

Hi all,

I have the following scenario:

My context looks like this:

Type (ValueNode) (0:N, 0:1, singleton=true)

**MyRoot (ValueNode) (0:N, 0:1, singleton=false)

****First (ValueAttrbiute string)

****Last (ValueAttrbiute string)

I populate the context this way:

IPrivateDynamicTableAppView.IMyRootNode rootNode = wdContext.nodeMyRoot();

IPrivateDynamicTableAppView.IMyRootElement rootElem = null;

IPrivateDynamicTableAppView.ITypeNode typeNode = wdContext.nodeType();

IPrivateDynamicTableAppView.ITypeElement typeElem = null;

typeElem = typeNode.createTypeElement();

typeNode.addElement(typeElem);

rootElem = typeElem.nodeMyRoot().createMyRootElement();

rootElem.setFirst("Omri");

rootElem.setLast("Cohen");

typeElem.nodeMyRoot().addElement(rootElem);

rootElem = typeElem.nodeMyRoot().createMyRootElement();

rootElem.setFirst("A");

rootElem.setLast("B");

typeElem.nodeMyRoot().addElement(rootElem);

rootElem = typeElem.nodeMyRoot().createMyRootElement();

rootElem.setFirst("C");

rootElem.setLast("D");

typeElem.nodeMyRoot().addElement(rootElem);

rootElem = typeElem.nodeMyRoot().createMyRootElement();

rootElem.setFirst("E");

rootElem.setLast("F");

typeElem.nodeMyRoot().addElement(rootElem);

// -


typeElem = typeNode.createTypeElement();

typeNode.addElement(typeElem);

rootElem = typeElem.nodeMyRoot().createMyRootElement();

rootElem.setFirst("Y");

rootElem.setLast("Z");

typeElem.nodeMyRoot().addElement(rootElem);

So now I have two "Type" elements:

1st element contains 4 "MyRoot" elements

2nd element contains 1 "MyRoot" element

I want to build two tables (actually the number of tables is "Type" node size)

This is the code in wdDoModifyView:

IWDTable iTab= (IWDTable) view.createElement(IWDTable.class,"Table");

iTab = (IWDTable)view.getElement("Table");

iTab.bindDataSource(wdContext.nodeType().getTypeElementAt(0).nodeMyRoot().getNodeInfo());

Iterator itr1 = wdContext.getChildNode("Type",0).getChildNode("MyRoot",0).getNodeInfo().iterateAttributes();

while(itr1.hasNext()) {

IWDTableColumn iTabCol = (IWDTableColumn) view.createElement(IWDTableColumn.class, null);

IWDTextView input= (IWDTextView)view.createElement(IWDTextView.class,null);

IWDAttributeInfo iWDInfo = (IWDAttributeInfo) itr1.next();

input.bindText(wdContext.nodeType().getTypeElementAt(0).nodeMyRoot().getNodeInfo().getAttribute(iWDInfo.getName()));

iTabCol.setTableCellEditor(input);

IWDCaption iCap = (IWDCaption) view.createElement(IWDCaption.class, null);

iCap.setText(iWDInfo.getName());

iTabCol.setHeader(iCap);

iTab.addColumn(iTabCol);

}

container.addChild(iTab);

// Same for 2nd table

iTab= (IWDTable) view.createElement(IWDTable.class,"Table1");

iTab = (IWDTable)view.getElement("Table1");

iTab.bindDataSource(wdContext.nodeType().getTypeElementAt(1).nodeMyRoot().getNodeInfo());

Iterator itr1 = wdContext.getChildNode("Type",0).getChildNode("MyRoot",0).getNodeInfo().iterateAttributes();

while(itr1.hasNext()) {

IWDTableColumn iTabCol = (IWDTableColumn) view.createElement(IWDTableColumn.class, null);

IWDTextView input= (IWDTextView)view.createElement(IWDTextView.class,null);

IWDAttributeInfo iWDInfo = (IWDAttributeInfo) itr1.next();

input.bindText(wdContext.nodeType().getTypeElementAt(1).nodeMyRoot().getNodeInfo().getAttribute(iWDInfo.getName()));

iTabCol.setTableCellEditor(input);

IWDCaption iCap = (IWDCaption) view.createElement(IWDCaption.class, null);

iCap.setText(iWDInfo.getName());

iTabCol.setHeader(iCap);

iTab.addColumn(iTabCol);

}

container.addChild(iTab);

Although the 'bindDataSource' is set to a different "Type" element I get the same table.

Also, I cannot use lead selection because changing the lead selection affects both tables...

What do I need to do to make it work? change context? table dynamic generation? or both?

Thanks,

Omri

p.s

Ignore the using of String literals, bizarre variables names - this code is for testing purposes (-:

Edited by: Omri Cohen on May 26, 2008 4:25 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

What you try is not supported, namely binding tables to non-singleton child nodes contained in elements of a parent node.

What you could do to achieve this is to create separate "MyRoot" nodes programmatically directly under the context root and bind the Table UI element data sources to these nodes.

Armin

former_member182374
Active Contributor
0 Kudos

Thanks Armin, problem solved by creating context dynamically.

Former Member
0 Kudos

Hi Armin,

I have the same problem. What is the best way to create those new nodes?

The node I have to map, is a model node. Its possible to copy all the elements from my node to the new node with a collectionsupplier or something? I dont know how it works.

Thanks in advance.

Answers (0)