关于ecmascript-6:什么是-sapushellContainer

43次阅读

共计 2112 个字符,预计需要花费 6 分钟才能阅读完成。

sap.ushell.Container 是一个 SAP Fiori Launchpad 的 JavaScript API,它提供了拜访 Launchpad 性能和服务的办法和属性。Container 对象由 SAP Fiori Launchpad 创立并提供给运行在 Fiori Launchpad 中的应用程序。在应用程序中,能够应用 Container 对象拜访 Fiori Launchpad 中的服务和性能。

sap.ushell.Container 提供了一系列办法和属性,用于与 Fiori Launchpad 进行交互,例如:

  • getService:获取指定名称的服务实例。
  • getRenderer:获取 Fiori Launchpad 的渲染器。
  • getShellConfig:获取 Fiori Launchpad 的配置。
  • setDirtyFlag:标记 Fiori Launchpad 数据已更改。
  • setHeaderTitle:设置 Fiori Launchpad 的页头题目。

这些办法和属性使应用程序能够与 Fiori Launchpad 进行集成和交互,从而实现与其余 Fiori 应用程序的合作和共享数据等性能。

总之,sap.ushell.Container 是一个 JavaScript API,它提供了拜访 SAP Fiori Launchpad 性能和服务的办法和属性,使应用程序可能与 Fiori Launchpad 进行集成和交互。

一个理论例子:

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title> 如何将本地 SAP UI5 利用配置到本地 Fiori Launchpad 中 </title>

    <script>
        window["sap-ushell-config"] = {
            defaultRenderer: "fiori2",
            applications: {
                "barcode-scan": {
                    title: "App 1",
                    description: "应用程序 1",
                    additionalInformation: "SAPUI5.Component=sap.ui5.walkthrough.app1",
                    applicationType : "URL",
                    navigationMode: "embedded"
                }
            }
        };
    </script>

    <script src="https://sapui5.hana.ondemand.com/test-resources/sap/ushell/bootstrap/sandbox.js"></script>
    <script src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"
        data-sap-ui-libs="sap.m, sap.ushell, sap.collaboration, sap.ui.layout" data-sap-ui-compatVersion="edge"
        data-sap-ui-theme="sap_fiori_3"
        data-sap-ui-resourceroots='{"sap.ui5.walkthrough":"./"}' 
        data-sap-ui-frameOptions="allow"></script>
    <script>
        sap.ui.getCore().attachInit(() => sap.ushell.Container.createRenderer().placeAt("content"))
    </script>
</head>

<body class="sapUiBody" id="content"></body>
</html>

最初的运行时成果:

这个例子的残缺源代码,参考笔者的这篇教程:

  • SAP UI5 利用开发教程之五十四 – 如何将本地 SAP UI5 利用配置到本地 Fiori Launchpad 中

service 的配置办法:

 window["sap-ushell-config"] = {
    services: {
      Foo: {
        module: "my.own.Foo"
        config: {header: "hidden"},
        adapter: {
          module: "my.own.FooAdapter",
          config: {foo: "bar"}
        }
      }
    }
  }
  sap.ushell.Container.getServiceAsync("Foo", "runtimeConfig")
      .then(function (Foo) {// Do something with the service});

留神:sap.ushell.Container 是 Unified Shell 的容器,用于治理渲染器、服务和适配器。该容器被设计为单例。请不要创立实例,而是通过命名空间 sap.ushell.Container 拜访地方实例。

正文完
 0