Skip to Content
author's profile photo Former Member
Former Member

Dynamic Node (Context) Binding problem


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?



Add comment
10|10000 characters needed characters exceeded

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jul 29, 2004 at 04:35 PM

    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.



    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

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

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


  • author's profile photo Former Member
    Former Member
    Posted on Aug 23, 2004 at 06:25 AM

    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(){


    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". ****/



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

    Thanks and Regards,

    Vishnu Prasad Hegde

    Add comment
    10|10000 characters needed characters exceeded