Skip to Content

Getting several dynamic tables from one context

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on May 26, 2008 at 04:52 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      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.

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.