【问题标题】:How to use custom control in Fiori launchpad of Cloud Foundry如何在 Cloud Foundry 的 Fiori 启动板中使用自定义控件
【发布时间】:2017-11-15 10:39:49
【问题描述】:

当我在 Cloud Foundry 的 Fiori 启动板中将 Monitor 应用程序部署为 SAPUI5 应用程序时,我遇到了一个错误:

404 未找到: https://sapui5.hana.ondemand.com/resources/sap/ui/iot/controls/IoTChart.js

我在 FLP 中的配置:

/xs-app.json:

{
  "source": "^/resources/sap/ui/iot/(.*)$",
  "destination": "IOTAS_CONTROLS",
  "target": "/sap/ui/iot/$1"
}

/mtad.yaml

modules:
    requires:
      - name: IOTAS_CONTROLS
        group: destinations
        properties:
        forwardAuthToken: true
        strictSSL: false
        name: IOTAS_CONTROLS
        url: ~{url}
resources:
  - name: IOTAS_CONTROLS
    properties:
    url: https://sapuiiot-sb.cfapps.sap.hana.ondemand.com

/Main.view.xml

     <mvc:View
            controllerName="monitor.controller.Main"
            xmlns:iot="sap.ui.iot.controls"
            xmlns:iotele="sap.ui.iot.elements"
          xmlns:action="http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1"
            displayBlock="false">
            <iot:IoTChart noOfHours="1" headerTitle="Temperature &amp; Gas Volume" subheaderTitle="Unit: Degree &amp; M3"/>

我尝试读取Controller.js中的“https://xxx-flp-sandbox.cfapps.sap.hana.ondemand.com/resources/sap/ui/iot/controls/IoTChart.js”,成功重定向到“https://sapuiiot-sb.cfapps.sap.hana.ondemand.com/sap/ui/iot/controls/IoTChart.js”,证明xs-app.json中的路由有效。

所以我的问题是,如果在 XML 视图中需要 sap.ui.iot.controls,它将始终使用域调用:https://sapui5.hana.ondemand.com,而 xs-app.js 中没有传递路径。

这个项目在webIDE中运行成功,因为在neo-app.json中定义了一个路由,重定向所有/resource/,请求总是在webIDE主机,但是在cloud foundry,它在sapui5.hana.ondemand主机

有什么建议吗?


试过了:

jQuery.sap.registerResourcePath("iotChart", "../../../../resources/sap/ui/iot/library")
jQuery.sap.require("iotChart")

//Still load host sapui5.hana.ondemand.com
var core=sap.ui.getCore();
core.loadLibrary("sap.ui.iot.controls");

【问题讨论】:

    标签: sapui5 sap-fiori


    【解决方案1】:

    通过在Component.js中添加一行解决:

    init : function() {
        jQuery.sap.registerModulePath("sap.ui.iot", "../../../../resources/sap/ui/iot");
    }
    

    此外,“sap.ui.iot”仍然不能在 rootView.view.xml 中声明,因为到那时,路径还没有注册。但是new sap.ui.controls.IoTChart()可以在控制器中使用

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多