on 03-19-2008 4:25 PM
I have two views. If on the second view user clicks cancel the user should be presented with a clean brand new first view. The first view contains dynamic elements tied to dynamic context.
wdContext.getChildNode("Employees",0).invalidate();
employees = wdContext.getNodeInfo().getChild("Employees");
employeeContainer = (IWDTransparentContainer)view.getElement("EmployeeContainer");
employeeContainer.destroyAllChildren();
for(int i=0; i<wdContext.currentCalculatedValuesElement().getOtherEmployeeSize(); i++)
{
buildInputField("employeeId", "emplUserId", i, 8, employees, employeeContainer, view);
}
.....
private static void buildInputField(String nodeInfoName,
String inputFieldName, int elementNumber, int fieldLength,
IWDNodeInfo nodeInfo,
IWDTransparentContainer container,
com.sap.tc.webdynpro.progmodel.api.IWDView view)
{
nodeInfo.addAttribute(nodeInfoName + elementNumber,"ddic:com.sap.dictionary.string");
IWDInputField inputField = (IWDInputField) view.createElement(IWDInputField.class,
inputFieldName + elementNumber);
inputField.setLength(fieldLength);
inputField.setReadOnly(false);
inputField.setEnabled(true);
inputField.bindValue(nodeInfo.getAttribute(nodeInfoName + elementNumber));
container.addChild(inputField);
}
It is blowing on the "nodeInfo.addAttribute(nodeInfoName + elementNumber,"ddic:com.sap.dictionary.string")" saying "com.sap.tc.webdynpro.progmodel.context.ContextException: DataNodeInfo(SelectionView.Employees): duplicate name for attribute employeeId0"
Thoughts?
Diane
Its clear..You are trying to create twice that attribute in context in the same place, which its not possible.
You MUST check if the attribute exists first, before trying to create it.
This probably can be achieved peeking on the attributeinfo, using getAttribute() method, which returns null if no attribute of that name exists.
IWDNodeInfo info = wdContext.node<nodeName>().getNodeInfo();
IWDAttributeInfo attrInfo = info.getAttribute(nodeInfoName + elementNumber);
if (attrInfo==null) //the attribute doesnt exists... yet
{
//ok create it
nodeInfo.addAttribute(nodeInfoName + elementNumber,"ddic:com.sap.dictionary.string");
}
Regards
Julio Herrera
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Method destroyAllChildren() destroys all children (of a container). In general, any 0:n aggregation Agg of a UI element leads to method destroyAllAgg() in the API.
This method removes all children of the container and destroys them from the view. This has the effect that their IDs can be used again.
It has nothing to do with the context however, only with the view layout.
I still wonder if you really need to create the context structure programmatically.
Armin
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.