简体   繁体   English

将自定义SAPUI5库添加到SAP Cloud Platform Fiori启动板(门户服务)

[英]Add Custom SAPUI5 Library to SAP Cloud Platform Fiori Launchpad (Portal Service)

I've created a custom SAPUI5 library with the SAP Web IDE and deployed the library to the SAP Cloud Platform. 我已经使用SAP Web IDE创建了一个自定义SAPUI5库,并将该库部署到SAP Cloud Platform。 The library is used by multiple SAPUI5 applications and works perfect when the apps are launched from the SAP Web IDE. 该库供多个SAPUI5应用程序使用,当从SAP Web IDE启动应用程序时,该库可以完美工作。 The dependency to the library is defined in the manifest.json of each application: 对库的依赖关系在每个应用程序的manifest.json中定义:

"dependencies": {"libs": {"custom.library"}: {}}}

Furthermore I've already added the correct path to the file neo-app.json . 此外,我已经为文件neo-app.json添加了正确的路径。

Now I've registered the SAPUI5 applications to the SAP Cloud Platform Fiori Launchpad. 现在,我已将SAPUI5应用程序注册到SAP Cloud Platform Fiori Launchpad。 I can start the Launchpad and see the tiles for the apps. 我可以启动启动板并查看应用程序的磁贴。 But when I start an app the following error occurs: Error: failed to load 'custom/library/library.js' from https://sapui5.hana.ondemand.com/1.52.17/resources/custom/library/library.js : 404 但是,当我启动一个应用程序时,会发生以下错误:错误:无法从https://sapui5.hana.ondemand.com/1.52.17/resources/custom/library/library加载“ custom / library / library.js” 。 js :404

How can I register the custom UI5 library to the Fiori Launchpad? 如何将自定义UI5库注册到Fiori Launchpad?

On SAP Community, you'll find this blog about the SAPUI5 Custom control library. 在SAP Community上,您将找到有关SAPUI5自定义控件库的博客 There it says that you need to add an entry into “routes” array of neo-app.json file for your newly deployed library. 在那里,您需要为新部署的库在neo-app.json文件的“ routes”数组中添加一个条目。 The entry shall look like this: 条目应如下所示:

{
       "path": "/webapp/resources/my/custom/control",
       "target": {
             "type": "application",
             "name": "mycustomlib", 
             "entryPath": "/"
       },
       "description": "Custom control library"
}

Here, “path” is the path you use in the dependency definition of your controller JS file. 在这里,“路径”是您在控制器JS文件的依赖项定义中使用的路径。 “name” in “target” clause contains the name under which you deployed the library into SAP Cloud Platform. “目标”子句中的“名称”包含将库部署到SAP Cloud Platform中的名称。

As SAP Fiori Crew pointed out, you need to create a route entry in neo-app.json for the SAP Cloud Platform router to know where to serve your library files from when requested by the applications. 正如SAP Fiori Crew指出的那样,您需要在neo-app.json为SAP Cloud Platform路由器创建一个路由条目,以从应用程序请求时知道从何处提供库文件。

A good way to find out the exact URL that needs to be added is checking the Network requests in your browser's Developer Tools, when trying to load the application in the Launchpad: 尝试在启动板中加载应用程序时,找出需要添加的确切URL的一个好方法是在浏览器的开发人员工具中检查网络请求:

对Cloud Fiori启动板中的library-preload.js的请求失败

In the example above, adding this entry to neo-app.json solved the problem: 在上面的示例中,将此条目添加到neo-app.json解决了该问题:

{
    "path": "/sap/ui5/1/resources/vplanner/common",
    "target": {
        "type": "application",
        "name": "vpfioricommon"
    },
    "description": "Common Library"
}

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

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