什么是 open.ushell.Container

举报
Jerry Wang 发表于 2023/03/23 10:04:52 2023/03/23
【摘要】 Open.ushell.Container 是一个 Open Fiori Launchpad 的 JavaScript API,它提供了访问 Launchpad 功能和服务的方法和属性。Container 对象由 Open Fiori Launchpad 创建并提供给运行在 Fiori Launchpad 中的应用程序。在应用程序中,可以使用 Container 对象访问 Fiori Lau...

Open.ushell.Container 是一个 Open Fiori Launchpad 的 JavaScript API,它提供了访问 Launchpad 功能和服务的方法和属性。Container 对象由 Open Fiori Launchpad 创建并提供给运行在 Fiori Launchpad 中的应用程序。在应用程序中,可以使用 Container 对象访问 Fiori Launchpad 中的服务和功能。

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

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

这些方法和属性使应用程序可以与 Fiori Launchpad 进行集成和交互,从而实现与其他 Fiori 应用程序的协作和共享数据等功能。

总之,Open.ushell.Container 是一个 JavaScript API,它提供了访问 Open 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>如何将本地 Open UI5 应用配置到本地 Fiori Launchpad 中</title>

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

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

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

最后的运行时效果:

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

service 的配置方法:

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

注意:Open.ushell.Container 是 Unified Shell 的容器,用于管理渲染器、服务和适配器。 该容器被设计为单例。 请不要创建实例,而是通过命名空间 Open.ushell.Container 访问中央实例。

【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。