on 2005 Jul 06 5:09 PM
Description of problem:
I am dynamically populating my context. Then I dynamically build my UI and try to bind my UI elements to the context. However I only see the FIRST value of the context element.
Context structure:
MatrixData 1..1 Singleton
Table 0..n Non-singleton
Row 0..n Non-singleton
Name string attribute
In wdDoInit() I populate the context as follows:
public void wdDoInit()
{
String [] sizeNames = new String [] {"Small", "Medium", "Large"};
IMatrixDataNode matrixDataNode = wdContext.nodeMatrixData();
IMatrixDataElement matrixDataEl = matrixDataNode.currentMatrixDataElement();
IContainerNode containerNode = matrixDataNode.nodeContainer();
for(int fitIdx = 0; fitIdx < 3; fitIdx++)
{
for(int materialIdx = 0; materialIdx < 2; materialIdx++)
{
ITableNode tableNode = matrixDataNode.nodeTable();
ITableElement tableEl = tableNode.createTableElement();
tableNode.addElement(tableEl);
IRowNode rowNode = tableEl.nodeRow();
for(int sizeIdx = 0; sizeIdx < sizeNames.length; sizeIdx++)
{
IRowElement rowEl = rowNode.createRowElement();
rowEl.setName(sizeNames[sizeIdx]);
rowNode.addElement(rowEl);
}
}
}
}
In wdDoModifyView I do the following:
public static void wdDoModifyView(IPrivateMatrixWithTransparentContainers2 wdThis, IPrivateMatrixWithTransparentContainers2.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
{
//@@begin wdDoModifyView
IWDTransparentContainer mainContainer = (IWDTransparentContainer) view.getElement("DynamicTransparentContainer");
mainContainer.destroyAllChildren();
IWDLabel lbl = createLabel(view, "Lbl1");
setMatrixHeadData(lbl, null);
int currentTable = 0;
int numRows = wdContext.getChildNode("MatrixData",0).getChildNode("Table", 0).getChildNode("Row", 0).size();
int uniqueId = 0;
mainContainer.addChild(lbl);
for(int i = 0; i < numRows; i++)
{
// Get the node info for row i
IWDNodeInfo nodeInfo = wdContext.getChildNode("MatrixData",0)
.getChildNode("Table", 0)
.getChildNode("Row",i)
.getNodeInfo();
// Get the AttributeInfo for attribute "Name"
IWDAttributeInfo attrInfo = nodeInfo.getAttribute("Name");
// Create a label and bind its text to the AttributeInfo
lbl = createLabel(view, "Lbl_" + (++uniqueId));
setMatrixHeadData(lbl, null);
lbl.bindText(attrInfo);
mainContainer.addChild(lbl);
}
//@@end
}
The result of this code is:
Small
Small
Small
Why is this????
If, instead of Label.bindText I use Label.setText, then the result is:
Small
Medium
Large
- which is the correct result.
Why is bindText not working correctly?
Any help much appreciated,
Walter Kahn
Hi,
I am not sure if i am understanding ur requirement.
As per ur requirement u r supposed to bind the attribute to the particular column and not to every row of that column
like "Table.Row"
Regards
Bharathwaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The bindText() is working correctly. If you bind a UI element property to a context attribute, then the value is given by the path from the context root, following the lead selection, to the node containing the attribute.
It's not clear to me what you want to achieve with the given code. You are referring to a node "Container" that is not shown in your context structure.
Can you describe your use case in more detail?
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry if my explanation was not clear. Here is what I am attempting to do:
I want to construct a number of "Tables".
Each "Table" has n "Rows".
Each "Row" has only one attribute - "Name".
In the example I posted I built 6 tables, each with 3 rows. I tried to get the first Table, loop through the Rows, and bind a new Label to the "Name" attribute of each Row.
// Get the node info for row i
IWDNodeInfo nodeInfo = wdContext.getChildNode("MatrixData",0)
.getChildNode("Table", 0)
.getChildNode("Row",i)
.getNodeInfo();
// Get the AttributeInfo for attribute "Name"
IWDAttributeInfo attrInfo = nodeInfo.getAttribute("Name");
and then use that IWDAttributeInfo in the bindText method.
Even though I use getChildNode("Row", i), and i loops from 0 - 3, I only ever see the value of the first "Name" attribute - "Small", repeated 3 times ("Small", "Small", "Small"). I expect to see: "Small", "Medium", "Large".
I know that I could use setText here, but in the project I am working on, I actually need these to be input fields, and I want to be able to update multiple tables/rows simultaneously, so I need to be able to bind to the value of every row in every table.
I hope that this explains more clearly what I am trying to do.
Walter
Hi,
Set text will set the value of the label with the attrinfo for evry iteration of the loop..
But when we use bind we are saying that it is linked to the attrinfo..
So whatever is there in attrinfo is displayed in all the labels..
Regards
Bharathwaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
70 | |
10 | |
8 | |
7 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.