如何將自定義XML檢視注入SAP Fiori Elements應用
Recently I need to put my own XML view into the application generated automatically by Smart Template. And I already found there is a question posted in forum Smart Templates: Custom View on Object Page asking for how to achieve it. So I write this blog for step by step guide.
Better to read first
It would be good if you have a draft understanding about how your application generated by Smart Template is rendered at runtime. You can read this blog My understanding about how object page in Smart Template is rendered for detail.
I just use an example to demonstrate. In the screenshot below, the red facet is automatically generated by Smart Template. The blue fact is actually rendered by my custom XML view.
Data binding in custom view
In my XML view I have a text with label “Long Text” and text bound to path = “to_LongText” and value = “long_text”.
What do these two properties mean? In SEGW you can get answer: to_LongText is navigation property and “long_text” is one of the property of the target type Z_I_Order_longtextType.
And the content of this property is stored in database table ZORDER_LONGTEXT, field LONG_TEXT, so you finally see the content “Jerry long text” in UI.
Register your custom view into manifest.json
You should declare your custom view usage in manifest.json file.
The most important part is the line marked in purple since it is responsible to tell framework exactly which postion your custom view should be put.
The naming convention is : + + .
Let me illustrate them further using example. For the screenshot above, if we translate “AfterFacet|Z_C_Order|GENEJERRY” into human readable sentence, it should be: put my custom view AFTER ( indicated by extension point: AfterFacet ) the automatically generated facet with id “GENEJERRY”. The binding context for custom view is “Z_C_Order”.
For the facet id “GENEJERRY”, you could find from annotation.xml in WebIDE.
How we can know which kinds of extension point are available in object page template? Switch your application to debug mode via Ctrl+Alt+Shift+P, refresh the application and you could observe lots of XML fragments are loaded.
Among them there is one fragment Sections.fragment.xml which is the place holder for all facets displayed in object page view.
Then you can find SAP has defined the AfterFacet extension point with naming convention format “AfterFacet|{entitySet>name}|{path: ‘firstLevelFacet>” which enables partner & customer to include their own view there.
event handling in custom view In my custom XML view, I have declared a function onPressed to semantic event press, which is implemented in corresponding controller of custom view.
The implementation of this press event is to simply increase the counter displayed in custom view.
Source code involved in this blog
I attach all source codes here for your reference.
controller
sap.ui.define(["sap/ui/core/mvc/Controller","sap/ui/model/json/JSONModel"], function(Controller, JSONModel) {"use strict";return Controller.extend("zsandbox.ext.controller.note", {
onInit: function() {
}
},
onPressed: function() {
var label = this.getView().byId("Jerry_label2");
var currentText = label.getText();
currentText = currentText || 0;
currentText = parseInt(currentText) + 1;
var data = { count: currentText};
label.setModel(new sap.ui.model.json.JSONModel(data),"json");
}});});
xml view
<core:View xmlns:core="sap.ui.core" xmlns:ui="sap.ui.layout" xmlns:layout="sap.ui.layout" xmlns:ca="sap.ca.ui" xmlns="sap.m"xmlns:form="sap.ui.layout.form" xmlns:crm="sap.cus.crm.lib.reuse.controls" controllerName="zsandbox.ext.controller.note"><ui:form.SimpleForm id="jerryform" layout="ResponsiveGridLayout">
<ui:content>
<Label id="Jerry_label1" text="Long Text"></Label>
<Text id="Jerry_Text1" binding = "{to_LongText}" text="{long_text}"></Text>
<Label id="Jerry_label2" text="{json>/count}"></Label>
<Button id="Jerrybutton" text="Click me" press = "onPressed"></Button>
</ui:content></ui:form.SimpleForm></core:View>
manifest.json
要獲取更多Jerry的原創文章,請關注公眾號"汪子熙":
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24475491/viewspace-2716712/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 如何給 SAP Fiori Elements 應用新增自定義按鈕
- SAP Fiori Elements List Report Smart Table Toolbar 的 XML 檢視實現XML
- SAP CAP Fiori Elements 應用配置 UI 的兩種方式以及自定義 index.htmlUIIndexHTML
- 如何給 SAP Fiori Elements 應用的欄位新增 value help
- 如何檢視 SAP Fiori Elements List Report Table 都支援哪些設定
- 如何在 SAP BTP 上通過 CDS view 快速建立 Fiori Elements 應用View
- 如何在 SAP Fiori Elements List Report 表格工具欄裡增添新的自定義按鈕
- SAP Fiori Elements 本地專案的 annotations.xml 檔案XML
- SAP Fiori Elements 應用裡和 Fiori 3 相關的外觀設定
- 使用Fiori Elements建立的SAP UI5應用,如何支援編輯功能UI
- SAP Fiori Elements 應用的 i18n 語法使用方式
- 使用程式碼給 SAP UI5 XML 檢視新增自定義 CSSUIXMLCSS
- 本地開發好的 SAP Fiori Elements 應用,如何部署到 ABAP 伺服器上?伺服器
- 答網友提問:使用 SAP Fiori Tools 建立的 Fiori Elements 應用,如何進行二次開發?
- 如何分辨 SAP Fiori Launchpad 裡的真假 Fiori 應用
- 如何免費試用SAP的Fiori應用
- 使用 mock 資料在本地執行 SAP Fiori Elements 應用的工作原理Mock
- 如何使用 mock 資料在本地執行 SAP Fiori ElementsMock
- SAP Fiori Elements 應用的 manifest.json 檔案執行時如何被解析的JSON
- SAP Fiori Elements 公開課第二單元學習筆記:Fiori Elements 架構筆記架構
- 使用 SAP Business Application Studio 建立 Fiori Elements 應用顯示 OData 資料APP
- 如何使用 controllerExtensions 給 SAP Fiori Elements 表格註冊事件響應函式Controller事件函式
- SAP Fiori應用索引大全索引
- 一步步學習 SAP CDS view Text Association 在 SAP Fiori Elements 中的應用View
- 如何將本地 SAP UI5 應用配置到本地 Fiori Launchpad 中UI
- SAP UI5 應用 XML 檢視的載入邏輯分析UIXML
- 如何在SAP Fiori應用裡使用React componentReact
- SAP UI5 應用如何載入自定義 ThemeUI
- SAP Fiori Elements 應用裡的 Title 顯示的內容是從哪裡來的
- SAP Fiori Elements controller extension 的載入原理Controller
- SAP Fiori Elements裡Drop down list的實現原理
- SAP Fiori應用索引大全工具和 SAP Fiori Tools 的使用介紹索引
- 自定義檢視指令
- SAP Fiori 應用 url 中的 DraftUUID 引數的含義RaftUI
- SAP Fiori 應用 Manage Workflows for Purchase RequisitionsUI
- SAP CRM Fiori應用和SAP JAM的整合配置
- 關於 SAP Fiori Elements 應用標題屬性(title) 的複製邏輯單步除錯除錯
- 如何使用Android自定義複合檢視Android