<core:View xmlns:core="sap.ui.core" xmlns:common="sap.ui.commons">
<common:Button text="Jerry" id="jerryButton"/>
</core:View>
The hierarchy of this sample application:
--- buttontutorial
|--- view
|- simple.view.xml
--- index.html
In all previous blogs so far, the button control is directly created by JavaScript code. So for the button defined in xml view, who is responsible for its creation? You might have already found a hint: in xml view I assign the button with id "jerryButton", and in the generated html code, the button tag has id "__xmlview0--jerryButton", which consists of the very id in the xml view and its parent, the xml view's id.
In Chrome network tag, use "xml" to filter the downloaded files. We find a promising function "parseTemplate" which might be able to answer our doubt.
Set a breakpoint on it and refresh the application. From the callstack we can understand the logic.
1. The xml view file containing the button control is downloaded.
2. The function parseTemplate of XMLTemplateProcessor is called. There is a recursive logic written within this function to go through all UI elements defined in the xml view and create a runtime instance for them one by one.
The button id is generated by this line:
Still remember the Button renderer introduced in the part 2 of this tutorial? In this blog, you have put the button control in an XML view. And in the runtime, this XML view is also rendered as tag div with id "__xmlview0". This rendering is done by XMLView renderer, as you could observe the load of it via Chrome network tab:
In this blog, the source code where the control instance defined in XML view is created in the runtime is introduced. In my daily work, I prefer to set breakpoint there to trouble shooting issues such as:
I list them here for your reference:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
26 | |
24 | |
21 | |
13 | |
11 | |
9 | |
9 | |
8 | |
8 | |
8 |