SAP Fiori Elements原理介绍之类型为Value Help的Smart Field工作原理

简介: SAP Fiori Elements原理介绍之类型为Value Help的Smart Field工作原理

In previous blog Currency example – how Smart field works, one simple smart field is introduced:


image.png


In this blog, let’s go further to study how the value help of currency field is implemented by framework:

image.png



Once we open F4 value help of currency field, we could see a new popup. both the value help on currency field itself and this popup dialog are implemented by UI5 framework, there is no application coding at all. The source code of xml view and controller remain unchanged compared with previous example – but indeed the UI element, the currency field, behaves differently – this is actually the meaning of “smart” – the behavior of UI element depends on the annotation defined in OData model metadata.


image.png


How could Framework know the currency field should be rendered as F4 value help?

We set breakpoint on this line which is already discussed in previous blog.


image.png


For the logic how the variable oMetaData.annotations.uom is parsed from metadata.xml, please refer to previous blog.

In OData Metadata, we use the following annotation to tell Framework that the UI element which is bound to “CurrencyCode” field in the model must be rendered as value list.


image.png


And the Target property is parsed in the runtime:


image.png


The calculated annotation from line 495 above is used to enable the original currency field with value help in line 1694 below by control Factory.


image.png


In the function addValueHelp, two new object instances ValueHelpProvider and ValueListProvider are created. They will be used later when F4 is pressed.


image.png


Finally, in the rendering process, since now the currency field has value help assigned, the corresponding UI5 icon is rendered by InputRender so that end user can easily identify the field has value help supported.


image.png


Implementation of F4 value help click

We have just now mentioned ValueHelpProvider. When F4 is pressed, it will react the press event and create an instance of ValueHelpDialog, which is a composite control acting as a container for all UI elements you could see in the popup dialog.


image.png


The controls are created separately as shown below:


image.png



Go button implementation

By default after you click F4 value help, the table is empty unless you click “Go” button.


image.png


The go button is implemented as instance of smartFilterBar created byValueHelpProvider.


image.png


The event handler of search is defined in line 317, the function _onFilterBarSearchPressed. In this event handler, it will delegate to _rebindTable.


image.pngimage.png

image.png

_rebindTable will fire a request to backend to ask for data for currency value list:


image.png


Once the response is available ( from mock data Currency.json in project ), the table is updated with data binding:


image.png


How the item selected from popup dialog could pass back to application

In the metadata, we have defined via annotation that the “Price” field has “CurrencyCode” field as its unit code.


image.png


Here below is the type definition for CurrencyCode, one property CURR for currency code and DESCR for currency description.


image.pngimage.png

image.png

It is this annotation which tells UI framework that once end user selects one currency from popup dialog, the value of field “CURR” in popup dialog must be passed back to field “CurrencyCode” in application.


image.png


How is this annotation parsed in the runtime? They are separately parsed in function addValueHelp we discussed previously and assigned to variable sValueListProprty and sLocalDataProperty.


image.png


image.png

When the first entry in currency list table is selected:


image.png


This selected state is passed into event handler via variable oControlEvent:


image.png


The key is parsed:


image.png


An event is raised with this selected key & text:


image.png


Now we are back to ValueHelpDialog:


image.png

Fire an OK event with selected key & text:


image.pngimage.png


相关文章
|
4月前
|
数据库 API
启用SAP Fiori之前的一些注意事项
启用SAP Fiori之前的一些注意事项
|
4月前
|
数据库
什么是 SAP S/4HANA 的 Brown Field 迁移和 Green Field 迁移
什么是 SAP S/4HANA 的 Brown Field 迁移和 Green Field 迁移
|
4月前
|
JavaScript 前端开发
试读版:如何找出 SAP 标准 Fiori 应用某个按钮点击后执行的 JavaScript 源代码
试读版:如何找出 SAP 标准 Fiori 应用某个按钮点击后执行的 JavaScript 源代码
SAP UI5 Link 控件的使用方法介绍 - 后续学习 Fiori Elements Smart Link 的基础试读版
SAP UI5 Link 控件的使用方法介绍 - 后续学习 Fiori Elements Smart Link 的基础试读版
|
4月前
|
前端开发 搜索推荐 开发者
SAP UI5 sap.m.Column 控件的 minScreenWidth 属性介绍
SAP UI5 sap.m.Column 控件的 minScreenWidth 属性介绍
|
4月前
|
JavaScript 前端开发 开发者
SAP UI5 控件 sap.m.ListBase 的 inset 属性的作用介绍
SAP UI5 控件 sap.m.ListBase 的 inset 属性的作用介绍
|
4月前
|
Web App开发 数据采集 前端开发
纯技术讨论:如何让 SAP UI5 应用无法被别人在浏览器里调试 - 这种做法不推荐试读版
纯技术讨论:如何让 SAP UI5 应用无法被别人在浏览器里调试 - 这种做法不推荐试读版
|
4月前
|
XML 存储 数据格式
SAP UI5 控件 customData 属性的应用介绍
SAP UI5 控件 customData 属性的应用介绍
|
4月前
|
前端开发 JavaScript API
SAP UI5 sap.ui.require.toUrl 的作用介绍
SAP UI5 sap.ui.require.toUrl 的作用介绍
|
4月前
|
搜索推荐
如何让 SAP UI5 Smart Table 支持多项选择(Multiple-Selection)试读版
如何让 SAP UI5 Smart Table 支持多项选择(Multiple-Selection)试读版