SAP UI5 按钮渲染原理

简介: SAP UI5 按钮渲染原理

To debug how is a button rendered in UI5 I created a project by using SAPUI5 application template via Web IDE. And add a button in View1.view.xml as below:



image.png

Then I added a breakpoint in ButtonRender.js to check how a Button is rendered in UI5.

In below picture we can see the render sequence of the controls:

UIArea -> Shell -> UIComponent -> XMLView -> NavContainer -> PageRender -> ButtonRender

After we execute code of line 198, the button’s text is not displayed on the page, so we know that we need to debug further.


image.png


In writeEscape() function, we can see the button’s text has been pushed in a buffer.

image.png



And UI5 not calls DOM native method to draw controls one by one, UI5’s strategy is rendering a batch of controls in one UIArea one time.

image.png



UI5 concatenates html elements which need to be drawn in a long String.


image.png


And then call append() function to draw these html elements.


image.png


jTarget is a JQuery object.


image.png


In append() function call DOM native function appendChild() to draw html elements.



image.png


As appendChild() is DOM native function we no need to jump into it, just step over line 10612, we can see that the button is displayed.


image.png


But the layout is strange, it is not display as we expected. we need to debug further. I continue to debug and step over many line’s of code, the html elements’ CSS style are still not change until I go to line 9184:

image.png



And I enter the two parameters of jQuery.event.dispatch.apply() in console, we can see that the two parameters are like below:


image.png


If we set breakpoint in EventProvider.prototype.fireEvent() function, the code doesn’t go there, that is to say this event is not a UI5 event.

In other words it will fire DOM native “load” event on DOM element “body”. And after that we can see the all the DOM elements’ including the button element’s CSS style is correct as we expected. To here, I think I have made clear of how is a button rendered in UI5.

image.png


相关文章
|
XML JSON 缓存
让UI忙碌的安卓Lottie动画渲染库(二)
上节我们讲述了Lottie开源库如何导入Android Studio但是,开源库是不断迭代的,所以我们也要及时更新
451 0
Element UI - el-table 渲染慢,卡的原因
Element UI - el-table 渲染慢,卡的原因
1703 0
|
5月前
|
JSON JavaScript 数据格式
Vue移动端框架Mint UI教程-数据渲染到页面(六)
Vue移动端框架Mint UI教程-数据渲染到页面(六)
39 0
|
7月前
|
存储 缓存 API
SAP 电商云 UI 服务器端渲染的建议架构
SAP 电商云 UI 服务器端渲染的建议架构
47 0
|
7月前
SAP 电商云 Spartacus UI 客户端模式下从服务器端渲染模式接收到的状态转移
SAP 电商云 Spartacus UI 客户端模式下从服务器端渲染模式接收到的状态转移
31 0
|
7月前
|
资源调度
SAP Spartacus UI 服务器端渲染的调试启动方式 - debug 模式
SAP Spartacus UI 服务器端渲染的调试启动方式 - debug 模式
55 0
|
8月前
|
前端开发
前端项目实战贰拾玖-​react-admin+material ui-页面数据进行渲染
前端项目实战贰拾玖-​react-admin+material ui-页面数据进行渲染
42 0
|
8月前
|
前端开发
前端项目实战贰拾伍-​react-admin+material ui渲染路由设计
前端项目实战贰拾伍-​react-admin+material ui渲染路由设计
51 0
|
8月前
|
前端开发
前端项目实战贰拾肆-​react-admin+material ui渲染树形结构
前端项目实战贰拾肆-​react-admin+material ui渲染树形结构
52 0
|
10月前
|
定位技术 API 图形学
unity-2D游戏官方案例--带视频案例(1)(层级渲染,物理碰撞,粒子动画,UI等多位基础一体化)
unity-2D游戏官方案例--带视频案例(1)(层级渲染,物理碰撞,粒子动画,UI等多位基础一体化)
129 1