Hallo Rakesh,
you have to pay attention when dealing with <i>context-to-model-binding</i> in respect of <b>model object relations</b>.
First think of a <b>model</b> as being a <i>model object graph</i> which is independent from the context. Its objects can have relations to one another.
Then think of the <b>context</b> as being a <i>structured hierarchy</i> of nodes containing node element collections, with node elements containing inner non-singleton nodes or nodes containing a singleton child node and so on.
<i>Context-To-Model-binding</i> at design time means, that you define bindings from model nodes in the context to model classes in the model as well as supplying relation roles in the context (nodes) based on given model class relations.
Then a tip when dealing with models at runtime: <u>Start implementing inside the model object graph and not in the context</u>. Instantiate model objects. Fill model object collections. Add these collections to other model objects based on the given model class relations.
Afterwards you have to set the reference between the root-level context node (element) and the root-level model object. This means you call
wdContext.nodeCustomer().bind(customerModelObject)
. With this method call the context model node (on root level) contains a model node element referencing the corresponding model object in the model object graph. That's all. As soon as Web Dynpro needs context data from deeper levels it follows the defined supplying relation roles, traverses the model object graph starting from the root model object and updates the references between model node elements and model objects.
I favor a <i>first-model-then-context</i> approach when programming the context-to-model-binding:
/* First model.*/ __Model_Input input = new __Model_Input(); __Model_Input_Table tableInput = new __Model_Input_Table(); input.addMyTableNode(tableInput); /* Then context: add model node element (with reference to model object) to a context model node. */ wdContext.nodeMyNode().bind(input);
In your case, populate the model object graph first with correctly associated model objects before binding the executable model object to the context node.
Greetings, Bertram
Add a comment