cancel
Showing results for 
Search instead for 
Did you mean: 

Delete dynamically created child nodes but not the attributes

former_member183915
Active Contributor
0 Kudos

Hi Experts ,

I am creating child nodes dynamically .For the first time the creation of child nodes work properly but in second iteration it gives error "com.sap.tc.webdynpro.progmodel.context.ContextException: DataNodeInfo(AdobeView1.ctx_vn_dynmcnd): duplicate name for child node child0 "

So i need to delete/ remove all the previously generated child nodes.

I tried wdContext.getContext().reset(true)

But this removes all the dynamically generated node and attributes both.I don't want the dynamically generated attributes to be reseted.

Any suggestions how this could be done.

Regards ,

Navya.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Try this... it works for me like a charm.

//Reset the context to delete all dynamically created nodes and attributes.

wdContext.wdGetAPI().reset(false);

Former Member
0 Kudos

If you dont want to remove ALL dynamically created nodes or attributes, you can try the following:

//To remove only a certain dynamically created node from the context.

wdContext.getChildNode("<whatever is your dynamic node name>", IWDNode.LEAD_SELECTION).getNodeInfo().remove();

//To remove specific dynamically created attributes from a node.

wdContext.getChildNode("<whatever is your dynamic node name>", IWDNode.LEAD_SELECTION)

.getNodeInfo().getAttribute("<dynamically created attribute name>").remove();

If you want to remove all dynamically created attributes in a dynamically created node, but want to retain the node itself, get the attribute list from the node info object, run at iterator on that list and run the above line of code providing the attribute names one at a time.

- Navneet.

Former Member
0 Kudos

Hello Navya,

I had this issue when I tried to clear off all the dynamically created attributes from the UI, so in the second iteration i found the duplicate name for the attribute.

I have tried reset() with all the possible options, but was in vain.

I have a strong feeling that, the method is not working as it is expected to be, so i ended up reusing the generated attributes.

Before generating the attribute, I will check if its already available and will generate only if its not present.

I know its not a perfect solution, but it works and can be a problem if you have the same attribute name with different type in the iterations.

basically reset() should work like the view.resetview().

Hope this helps

Regards

Senon