cancel
Showing results for 
Search instead for 
Did you mean: 

resetting dynamic view entries

former_member540174
Participant
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

former_member540174
Participant
0 Kudos

WIll do - but then what is destroyAllChildren() doing for me?

Diane

Former Member
0 Kudos

Dunno, maybe destroying/clearing all UI elements contained inside that container (in view!).. that wouldnt destroy all those attribute already created (in context) i guess.

I guess what u need in that case (deleting contexts) would be:

wdContext.node<nodeName>().invalidate();

Julio

Former Member
0 Kudos

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

Answers (0)