SAPUI5中另一个应用程序的访问控制器 [英] Access controller of another application in SAPUI5

查看:21
本文介绍了SAPUI5中另一个应用程序的访问控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一台 SAP 服务器中有一些 SAPUI5 应用程序.所有应用程序都将部署在 ERP 服务器版本 6.0 中.

I have some SAPUI5 applications in one SAP server. All the applications will be deployed in an ERP Server Version 6.0.

所有应用程序在我们的 ERP 服务器中都有一个访问 URL,可以通过 SAP NetWeaver 进行检索.所有 url 的格式都是 commonPart/applicationName/index.html.所有这些应用程序都可以通过 Fiori 启动板应用程序访问.

All the applications has a access url in our ERP server that can be retrieved through the SAP NetWeaver. All the urls have the format commonPart/applicationName/index.html. All of these application will be accessible through a Fiori launchpad application.

现在我有一个控制器,必须在我的所有应用程序之间共享.有没有什么方法可以让我不用复制过去就可以共享这个控制器?

Now I have a controller that has to be shared between all my applications. Is there any method that I can share this controller without copy and past?

提前致谢

推荐答案

您可以为 SAP Fiori 应用程序创建可重用的库项目.将您的 BaseController 放在该库中.然后在您的应用程序项目中导入库并从 BaseController 扩展您的应用程序控制器.

You can create a reusable library project for SAP Fiori applications. Put your BaseController in that library. Then import the library in your application project and extend your application controller from BaseController.

在基础项目的根文件夹中定义 library.js

Define library.js in root folder of your base project

sap.ui.define(["jquery.sap.global",
            "sap/ui/core/library"], // library dependency
function(jQuery) {

    "use strict";
    // delegate further initialization of this library to the Core
    sap.ui.getCore().initLibrary({
        name: "mylibrary.reuse",
        version: "1.0",
        dependencies: ["sap.ui.core"],
        types: [],
        interfaces: [],
        controls: [],
        elements: [],
        noLibraryCSS: true
    });

    return mylibrary.reuse;

}, /* bExport= */ true);

在其 JS 文件中声明 BaseController

Declare the BaseController within it's JS file

 jQuery.sap.declare("mylibrary.reuse.BaseController");
 /** Controller Definition **/

在 neo-app.json 中定义和公开您的库的入口点

Define and expose entry points to your library in neo-app.json

 {
   "routes": [{
    "path": "/resources/mylibrary/reuse",
    "target": {
        "type": "application",
        "name": "myreuselibrary",
        "entryPath": "/mylibrary/reuse"
    },
    "description": "SAPUI5 Resources"
},

}

然后在应用项目中导入上述库,做JQuery.require()得到BaseController然后扩展.

Then import the above library in application project, do JQuery.require() got BaseController and then extend it.

我希望这会有所帮助.

这篇关于SAPUI5中另一个应用程序的访问控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆