专栏首页Jerry的SAP技术分享SAP UI5应用如果遇到数据绑定问题时,应该如何自己定位问题?

SAP UI5应用如果遇到数据绑定问题时,应该如何自己定位问题?

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.

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

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

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

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.

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:

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:

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

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.

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:

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

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.

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

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

我来说两句

0 条评论
登录 后参与评论

相关文章

  • SAP offline plugin简介

    The Offline OData plugin provides offline OData support to Kapsel applications. ...

    Jerry Wang
  • SAP S/4HANA里如何创建Customer主数据以及执行后续处理

    1, Launch tcode: BP and select the Organization 2, Maintain the information for...

    Jerry Wang
  • 如何启用SAP Business by design里的Correction Invoice功能

    Subject: [Tip] How to enable the function Correction Invoice for customer invoic...

    Jerry Wang
  • Protocol Buffer Basics: Java(一)

    This tutorial provides a basic Java programmer's introduction to working with pr...

    阿泽
  • How to Accelerate Your Python Deep Learning with Cloud GPU?

    This afternoon, I trained a 3-layers neural network as a regression model to pre...

    王树义
  • 用数学为爱情保鲜

    16/5/22 数学的力量 爱情数学 心得: 数学的力量是很强大的,它存在于我们的生活中,影响着我们的生活,无处不在。 说得简单一些,数学就是一门研究...

    杨熹
  • Why Hire Top Developers From India?

    Creative professionals and talented developers are key players for making a busi...

    用户7067505
  • 【转】面试官必读:Before you are going to interview candidates…

    Here is some tips before you are going to interview new candidates:

    崔文远TroyCui
  • Deploying to Amazon EC2 in Mulesoft

    The EC2 plugin allows you to create Amazon machine instances (AMIs) of your exis...

    用户6790598
  • bochs compile 编译

    The standard compile uses the configure script, but the Windows platform cannot ...

    战神伽罗

扫码关注云+社区

领取腾讯云代金券