扩展的应用程序描述符文件和无效的数据源

问题描述 投票:0回答:3

我有两个应用程序:

  • hrportalcore:带有BaseController的核心应用程序,...
  • hrportalrequestleave:从 hrportalcore 应用程序扩展的示例应用程序

hrportalcore 具有命名空间 de.example.core 并且还维护着 dataSources。 (manifest.json 中的

sap.app.dataSources
)。数据源是:

[...]
"HRPOJavaLeave": {
   "uri": "<path>",
   "type": "OData",
   "settings": {
       "annotations": [],
       "odataVersion": "2.0",
       "localUri": ""
   }
}
[...]

数据源在扩展应用中可以正常使用,但控制台出现以下错误:

说数据源有错误,但是可以使用(奇怪?)。

另一件事是,Component-preload.js 文件一次从错误的位置加载。该应用程序工作没有问题,但正如所说的那样,它是从错误的位置加载一次?

我的hrportalrequestleave的manifest.json看起来像在扩展部分(

sap.ui5.extends
):

[...]
"extends": {
    "component": "de.example.core",
    "extensions": {}
},
[...]

父级在 neo-app.json 中正确定义为

/parent
以显示给 hrportalcore。

jQuery.sap.declare("de.example.request.leave.Component");

// use the load function for getting the optimized preload file if present
if (!jQuery.sap.isDeclared("de.example.core.Component")) {
    sap.ui.component.load({
        name: "de.example.core",
        // Use the below URL to run the extended application when SAP-delivered application is deployed on cloud
        url: jQuery.sap.getModulePath("de.example.request.leave") + "/parent"
            // we use a URL relative to our own component
            // extension application is deployed with customer namespace
    });
}

this.de.example.core.Component.extend("de.example.request.leave.Component", {
    metadata: {
        manifest: "json"
    }
});

这一切都发生在 HANA 云平台的 Fiori Launchpad 中

sapui5 sap-fiori sap-cloud-platform
3个回答
1
投票

解决方案

hrportalcore

manifest.json:始终使用您在 HCP 上的

applicationVersion
属性中部署的最新版本:

{
    "_version": "1.2.0",
    "sap.app": {
        "_version": "1.2.0",
        "applicationVersion": {
            "version": "1.6.2"
        },
...
hrportalrequestleave

manifest.json(扩展项目):如上所述,始终使用您在 HCP 上的

applicationVersion
属性中部署的最新版本。

找不到数据源?!

如果您有一个扩展项目(如 hrportalrequestleave < hrportalcore), then the manifest.json),两个应用程序都会像

jQuery.extend(...)
一样合并。所有属性,期待
sap.app
树,因为它真正描述了应用程序,并且无法从父扩展复制。

现在,当您使用父扩展中的

dataSource
时,将找不到它。这意味着对您来说,您必须在扩展项目
manifest.json
中定义 sap.app.dataSources


0
投票

日志中的错误

“应用程序依赖项 de.example.core.Component 出错:未找到描述符”

表明manifest.json包含对“de.example.core.Component”而不是“de.example.core”的依赖。根据您的代码片段,“扩展”依赖项是正确的。你还有其他依赖吗?

后端的 AppIndex 计算依赖项的传递闭包,如果找不到具有该 ID 的安装,则会在客户端创建并记录上述错误。

如果您的manifest.json看起来不错,但过去可能包含错误的依赖项,则可能需要重新运行AppIndex(或安排其定期运行)。

尽管存在配置错误,但应用程序仍能正常工作,这是由您上面显示的代码引起的。它从显式计算的 URL 显式加载 de.example.core 组件。但在此步骤之前,框架已经尝试根据 manifest.json 中的信息加载它,并且缺少有关显式 URL 的信息。

顺便说一句:计算 URL 的代码表明,即使在修复了 manifest.json 后,AppIndex 也可能找不到该组件,因为它似乎存储在 de.example.request.leave 应用程序的子包中。不确定 AppIndex 是否可以处理此问题(如果嵌套组件在顶级清单.json 中被列为嵌入式组件,它可以处理它们,但我不确定它是否可以识别依赖项部分中的此类嵌入式组件。因此可能会尝试加载嵌入组件,尽管它已经与封闭组件一起加载了。


0
投票

我手动将数据源添加到扩展 fiori 应用程序的清单文件中。数据源与标准应用程序相同。这会影响功能吗?目前扩展应用程序工作正常

© www.soinside.com 2019 - 2024. All rights reserved.