on 05-26-2008 3:23 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.