I will use the field “ClosingDate” to demonstrate my favorite approach to trouble shoot field binding issue. Generally speaking, the issue could be summarized as that although you have bound your UI control to a given field of a Json or odata model, however in the runtime nothing is displayed in the control.

In order to find the root cause of such issue, we need to understand the logic that how is the field value in a model bound to our control and finally displayed in the UI.

/wp-content/uploads/2015/10/clipboard1_800940.png

The field above, “Closing Date”, is bound to the model field “ClosingDate” in the xml view.

/wp-content/uploads/2015/10/clipboard2_800941.png

In the runtime, such binding relationship will be represented by an instance of Binding.

/wp-content/uploads/2015/10/clipboard3_800946.png

The corresponding js file for each kind of property binding could be found from this folder:

/wp-content/uploads/2015/10/clipboard4_800947.png

Within this folder, you can find dedicated js file for OData Model property, Json Model property and i18n Model property accordingly.

The Binding and ClientPropertyBinding are the prototype of these concrete binding type.

/wp-content/uploads/2015/10/clipboard5_800949.png

Since there are so many controls which have been bound to model fields, the constructor of Binding will be called again and again for each binding relationship.

As I am only interested with “ClosingDate”, so I make small modifications on the Binding.js directly in Chrome.

Then I resume the execution of debugger and soon the debugger stops at the very point where the mapping instance for “ClosingDate” is instantiated:

/wp-content/uploads/2015/10/clipboard6_800950.png

Every binding instance has one attribute sPath to indicate which model field it represents, and another attribute oValue, which contains the actual content of the model field, which will be rendered in the control.

Now I would like to know for the model field “ClosingDate”, when the oValue will be filled and where the content of oValue come from. So I switched to the inner callstack:

/wp-content/uploads/2015/10/clipboard7_800951.png


The value will be filled by this._getValue():

/wp-content/uploads/2015/10/clipboard8_800952.png

And now we are clear: the oValue of current binding instance comes from the corresponding node of OData model, to be exactly using UI5 terminology, from the binding Context.

/wp-content/uploads/2015/10/clipboard9_800953.png

The OData Model instance has one attribute “oData” which contains detail data for each list item. ODataModel._getObject will get the binding context of current binding property instance and then fetch the property value from that binding context:

/wp-content/uploads/2015/10/clipboard10_800957.png

/wp-content/uploads/2015/10/clipboard11_800958.png

Now this.oValue is filled and this very value will be displayed inUI.

/wp-content/uploads/2015/10/clipboard12_800959.png

When the control containing any attributes which are bound to a property of Model, the function “getExternalValue” of related property binding instance will be called. The result will be displayed in UI.

If there is any formatter defined for the property binding by application, for example in my application I have defined my custom formatter “dateFormatterMaster”. In line 79 framework will call such formatter if there is any.

/wp-content/uploads/2015/10/clipboard13_800960.png


And through debugging and callstack, I can see my formatter is called.

/wp-content/uploads/2015/10/clipboard14_800961.png

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

Leave a Reply