简体   繁体   English

如何在Cloud Foundry的Fiori启动板中使用自定义控件

[英]How to use custom control in Fiori launchpad of Cloud Foundry

As I deploy Monitor app as a SAPUI5 app in Fiori launchpad in Cloud Foundry, I encountered an error: 在Cloud Foundry的Fiori启动板上将Monitor应用程序部署为SAPUI5应用程序时,遇到错误:

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

My Configuration in FLP: 我在FLP中的配置:

/xs-app.json: /xs-app.json:

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

/mtad.yaml /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 /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"/>

I have tried to read " https://xxx-flp-sandbox.cfapps.sap.hana.ondemand.com/resources/sap/ui/iot/controls/IoTChart.js " in Controller.js , it is redirected to " https://sapuiiot-sb.cfapps.sap.hana.ondemand.com/sap/ui/iot/controls/IoTChart.js " successfully, which proved the route in xs-app.json worked. 我试图阅读Controller.jshttps://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的路由有效。

So my question is, it seems if sap.ui.iot.controls is required in XML View, it will always called with domain: https://sapui5.hana.ondemand.com without pass route in xs-app.js. 所以我的问题是,似乎如果XML View中需要sap.ui.iot.controls ,它将始终使用域: https://sapui5.hana.ondemand.com : sap.ui.iot.controls进行调用,而在xs-app.js中没有通过路由。

This project is run successfully in webIDE, because in neo-app.json , it defined a route, which redirect all /resource/ , request is always in webIDE host, but in cloud foundry, it is in sapui5.hana.ondemand host 此项目在webIDE中成功运行,因为在neo-app.json ,它定义了一条路由,该路由将所有/resource/重定向,请求始终在webIDE主机中,而在Cloud Foundry中,它在sapui5.hana.ondemand主机中

Any Suggestion? 有什么建议吗?


Tried: 尝试过:

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");

Solved by add one line in Component.js: 通过在Component.js中添加一行来解决:

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

Besides, "sap.ui.iot" still cannot declared at rootView.view.xml, because by that time, path is not registered. 此外,“ sap.ui.iot”仍然不能在rootView.view.xml上声明,因为到那时,路径尚未注册。 But new sap.ui.controls.IoTChart() can be used in controller 但是new sap.ui.controls.IoTChart()可以在控制器中使用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM