如何检测SAP UI5应用里控件的初始化和析构时间点

简介: Recently in order to resolve some internal incidents, I have the requirement to monitor the control registration and deregistration, that is, I need to know when and where the control is created and destructed. If you don’t know where to set breakpoint to achieve it, just follow me

Recently in order to resolve some internal incidents, I have the requirement to monitor the control registration and deregistration, that is, I need to know when and where the control is created and destructed. If you don’t know where to set breakpoint to achieve it, just follow me


image.png


For example, I have a list and all the information I have is its id “list”, as defined in xml view:

image.png


image.png


(1) Open Chrome development tool, get the core instance via sap.ui.getCore().


image.png


(2) There is one function byId available on this core instance, type “core.byId” in console and put the mouse on the returned “function anonymous()”.


image.png


Now you can click it to see detail:


(3) Once clicked, the implementation will be automatically opened. The main logic is in line 41. Till now we cannot know much about it. So set a breakpoint on line 41.


image.png


(4) Type “core.byId(“list”)” in console and press enter key, breakpoint triggered. Our hard coded argument “list” is passed in.


image.png


Now we reached Core.js which contains the implementation of byId function.


image.png


And the byId function just simply return the corresponding entry in a big object “this.mElements” if there exists such one.


image.png


By going through this file soon I find what I am looking for.

The control registration is just to add a key ( control id ) – value ( control instance ) pair to the central container “this.mElements”. This could be found in line 1921.

The control deregistration is just to remove the entry from container – line 1930.


image.png


(5) When I set the breakpoint in line 1921 trying to capture the time when the list instance is created. What annoying me is the breakpoint is triggered again and again since there is so many controls in my ui.

Then I just wrote a small pieces of code below:


image.png


And now it works like a charm. The breakpoint is triggered only once for the very list creation, the runtime id of list is “__xmlview6–list”.


image.png


Then through callstack I get to know that the list creation is triggered by the successfully load and parse of the xml view where the list is defined.


image.png


I would find the source code of xml view which is to be parsed by XMLTemplateProcessor, which is exactly the same as the one in my IDE.


image.pngimage.png



You can also use the same approach to observe the control deregistration timeslot:


image.png


Hope this small tip can help you learn control life-cycle knowledge by debugging yourself


相关文章
|
7月前
|
XML Web App开发 JavaScript
通过 FileUploader 的初始化,了解 SAP UI5 应用的 StaticArea 初始化逻辑
通过 FileUploader 的初始化,了解 SAP UI5 应用的 StaticArea 初始化逻辑
33 1
|
7月前
|
XML 数据格式 容器
SAP UI5 SimpleForm 控件实例的初始化调试
SAP UI5 SimpleForm 控件实例的初始化调试
48 0
WPF界面异常:未将对象引用设置到对象实例
WPF界面异常:未将对象引用设置到对象实例
WPF界面无法正常显示(资源引用,如转换器),但程序正常运行
WPF界面无法正常显示(资源引用,如转换器),但程序正常运行
WPF界面无法正常显示(资源引用,如转换器),但程序正常运行
|
容器
如何检测SAP UI5应用里控件的初始化和析构时间点
如何检测SAP UI5应用里控件的初始化和析构时间点
如何检测SAP UI5应用里控件的初始化和析构时间点
Qt-第一个QML程序-4-自定义按钮类,动画,状态
上篇中,我们写到了自己定义了一个按钮,但是呢,按照这样的写法,要写一个程序出来,那要累死了,所以,qml给我的感觉就是各种随便调用,所以了,可以自己写一个自己Button的qml,这样在以后用到了,就可以直接使用了。
361 0
Qt-第一个QML程序-4-自定义按钮类,动画,状态
Qt [GC9-8]:让我们的程序可以随意的移动(重载鼠标事件)
Qt [GC9-8]:让我们的程序可以随意的移动(重载鼠标事件)
138 0
Qt [GC9-8]:让我们的程序可以随意的移动(重载鼠标事件)
PyQt5 技术篇-QSpinBox选值框值改变触发事件实例演示,获取QSpinBox组件的值,选值框的边界值设置方法
PyQt5 技术篇-QSpinBox选值框值改变触发事件实例演示,获取QSpinBox组件的值,选值框的边界值设置方法
582 0
PyQt5 技术篇-QSpinBox选值框值改变触发事件实例演示,获取QSpinBox组件的值,选值框的边界值设置方法
|
XML 前端开发 JavaScript
SAP UI5 的初始化过程
SAP UI5 的初始化过程
118 0
SAP UI5 的初始化过程