天天看点

如何找到SAP UI5控件ID生成的准确时间点和代码位置

In one of my blog How to monitor the control registration and deregistration ,

I demonstrate one approach to enable you to find the location where a given control which you are interested is created or destructed.

Still use the master list below for example:

如何找到SAP UI5控件ID生成的准确时间点和代码位置

In the xml view, its id is defined as “list”:

如何找到SAP UI5控件ID生成的准确时间点和代码位置

And in the runtime, the id has naming convention “__xmlview[id]–list”. Where is this runtime id generated?

如何找到SAP UI5控件ID生成的准确时间点和代码位置

Following the tips in my previous blog, we can easily find the callstack where control runtime id is generated.

By reading the code if seems the runtime id did consist of container xml view id and the control id itself defined in xml view.

如何找到SAP UI5控件ID生成的准确时间点和代码位置

In order to prove my assumption, I wrote the following code and re-launch my UI. This time the breakpoint is triggered, with the very list id “list” passed in.

如何找到SAP UI5控件ID生成的准确时间点和代码位置

After I debugged into function createId in line 334, I get my guess verified: the runtime id of a control consists of its container view’s id and its own id defined in the container view, as displayed below:

如何找到SAP UI5控件ID生成的准确时间点和代码位置