打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
SAP Cloud for Customer页面根据后台数据响应的刷新原理介绍

Recently I am working with partner and they are asking for the reason of one UI5 refresh behavior.

I simply display the BO ID, Description, Create Date and NodeID for demonstration purpose.

The event handler bound to the Click Me button:

Observed behavior

Suppose I have two Service Request BO instance in the system: ID 333 with creation date 26.02.2014 ID 1071 with creation date 06.09.2017 By default BO detail data for ID 1071 is displayed:

After I type ID 333 in the input field and press button, the data for BO 333 is read from backend and displayed:

However, if I input an invalid id for example 333a, there is no refresh in UI. This behavior is complained by customer.

How C4C UI refreshes according to response from backend

Let’s first investigate on the first scenario – read against a valid BO id. For example currently BO ID 333 is displayed in UI, and we type ID 1071 and press Click Me button.

(1) Add sap-ui-debug=true in url to load the debug version of UI5 source code.

(2) Set breakpoint on file UpdateService.js, function _updateData. Type ID 1071 and click button, the BO data will be read from backend. Once response is available, this function will be called. From debugger we can find out that the BO detail data is already contained in the response.

And there is a for loop performed on this data structure, to write the latest data back to UI controller’s corresponding model node field. Below screenshot shows the model field ID in Root node will be merged with the latest data, 1071.

In function setRawValue in DataField.js, the new value is set only on the condition that it does not equal to the old value ( see the if evaluation in line 917 ).

Please notice that the assignment in line 922 will NOT lead to the UI refresh with new value 1071 displayed, because till now, only the latest value of DataField is changed, but the underlying DOM node which actually controls the html display remains unchanged.

The real UI refresh is triggered in file TextField.js, function setValue.

The underlying DOM element for BO ID input field is retrieved in line 635 and stored in variable oInput, so oInput.value contains the old value currently displayed in the UI.

If the latest value does not equal to the current value ( if evaluation in line 636 ), the new value will be filled to the DOM element in line 652.

Why UI does not refresh at all if an invalid BO ID is specified

Based on previous finding, the answer to this question could be easy.

When an invalid BO ID is used to perform read operation, in the response the fields used to bind to UI element do not exist at all.

Just compare it with the response for a normal case where a valid BO ID is used to read.

In this case, the corresponding setValue for each model field bound to UI element will NEVER have any chance to be executed, as they could NEVER be executed by the for loop in line 115 at all. As a result the UI remains unchanged as the state before Click Me button is clicked.

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Zlibrary | 全球最大电子书资源网站最新网址 新手使用指南
如何访问behance设计网站?
手机怎么定位对方的手机所在位置?学会这个小窍门,定位再也不用愁
电脑🖥️键盘上所有英文键的意思
宏--战士宏--通用 老雷
6个完全免费的录音转文字神器,让你事半功倍
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服