SAPUI5实现标准应用View替换的开发实践

来源:互联网 发布:尚学堂大数据课表 编辑:程序博客网 时间:2024/06/05 16:05

前言

SAP Fiori虽然提供了拓展应用的开发模式,但是由于标准应用的拓展点(Extension)不满足我们的要求,所以部分需求场景下需要替换掉原有的view,进行复制粘贴重新编辑。

实现方案

便于理解我们用代码来解释一下这个方案:

下面是一个标准app的view:

<mvc:View xmlns="sap.ui.commons" xmlns:mvc="sap.ui.core.mvc">    <TextView text="SAP View 'Sub1' - this one should have been replaced by the customer View"></TextView>  </mvc:View>

下面是一个自定义view的拓展代码

<mvc:View xmlns="sap.ui.commons" xmlns:mvc="sap.ui.core.mvc">    <TextView text="Custom View 'Sub1' - this one replaces the original SAP View 'Sub1'"></TextView>    </mvc:View>

如果要实现view的替换需要在component.js中编写如下代码:

customizing: {    .....some more content    "sap.ui.viewReplacements": {        "samples.components.ext.sap.Sub1": {            viewName: "samples.components.ext.customer.CustomSub1",            type: "XML"        }    },    .....some more content

简单吧,拓展和替换view整体区别就在这几行代码。

大家可以测试一下!

0 0
原创粉丝点击