Skip to Content
0
Former Member
Jul 06, 2005 at 04:09 PM

Help! Problem binding UI elements to Context elements

84 Views

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