cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Node (Context) Binding problem

Former Member
0 Kudos

Hi

I'd like to bind a view context's node to controller context's node dynamically. I mean I should be able to change the binding between view context and controller context dynamically.

How can I achieve this?

Sincerely,

Rajit.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Rajat,

Yes the method suggested by Stefan definitely helps, but only if the node at the source is created dynamically.

What I mean is suppose, you have created two nodes in two different controllers(In different webdynpro components also), say, Node1 and Node2. Let Node1 be the source Node and Node2 be the target node. Say you have created both Node1 and Node2 statically. Now as per requirement, you map Node1 to Node2 using the APIs in IWDNodeInfo, as suggested by Stefan. It works fine. Now suppose you want to map Node1 to another target node, say Node3. When you say reset(Using wdContext.wdGetAPI().reset();), all the dynamically created attributes and their mapping goes off, however since you had created Node1 statically, its mapping is not reset. So when you try to create a mapping from Node1 to Node3, it errors out saying, mapping cannot be set more than once.

So the ideal solution in your case would be, to create at least the source node dynamically. So when you say reset, since the node is created dynamically, even the node is distroyed. You can recreate the node. I have attached the code snippet here... Hope it helps.....

public void constructMappingDynamically(){

wdContext.wdGetAPI().reset();

IWDNodeInfo sourceNodeInfo = wdThis.wdGetAPI().getContext().getRootNodeInfo().addMappedChild("DynamicChildNode", null, true, false,false,null, false, true);

/**** Here "DynamicChildNode" */ is the name of the source node ****/

sourceNodeInfo.setMapping(<targetController>.wdGetAPI().getContext(),<resultsContextPath>, true);

/**** Here <resultsContextPath> indicates the path of the target node in the target controllers context. If the

target node is directly under the root node, then specify the node name, for eg, "Node2"(refer explanation above).

If the target node, say Node4 is the child of another node, say, Node2, then specify "Node2.Node4". ****/

sourceNodeInfo.addAttributesFromDataNode();

}

Hope this helps. Let me know if you have any other queries/comments/suggestions.

Thanks and Regards,

Vishnu Prasad Hegde

Former Member
0 Kudos

Hi Rajit,

please have a look at the IWDNodeInfo API documentation. There are methods adding mapped attributes/nodes from and to arbitrary controller contexts.

If you want to change the mapping more than once during runtime using different mapping targets, reset the (partially) mapped context, which removes all dynamically created nodes/attributes.

Hope that helps.

Regards

Stefan

Former Member
0 Kudos

Invalidating the node itself also seems to work, ie. wdContext.nodeList.invalidate();

Stefan, I assume you were referring to calling wdContext.getContext.reset();

Michael