【问题标题】:how to close CrossApplicationNavigation pages from script with button如何使用按钮从脚本关闭 CrossApplicationNavigation 页面
【发布时间】:2019-05-31 09:04:45
【问题描述】:

在我目前正在开发的应用程序上, 我有几个指向标准 sap 后端事务的超链接,例如 BP、PDL 等。 我通过 CrossApplicationNavigation 打开它们。 他们打开新标签。

在我的主应用程序上,我实现了一个按钮来关闭每个选项卡并返回到根视图。

我尝试了以下方法: Script to close other tabs or browser

这是我的代码:

            var oCrossAppNavigator = sap.ushell.Container.getService("CrossApplicationNavigation");
            var oExtUi = oEvent.getSource().getText();
            var hash = oCrossAppNavigator.hrefForExternal({
                target: {
                    semanticObject: "ZSIMM_PDL",
                    action: "display"
                },
                params: {
                    "UtilitiesPDL": oExtUi
                }
            });
            var url = window.location.href.split("#")[0] + hash;
            this._oComponent = sap.ui.component(sap.ui.core.Component.getOwnerIdFor(this.getView()));
            this._myModel = this._oComponent.getModel("oModelWindow");
            this._myModel.setProperty("/Window", window);
            sap.m.URLHelper.redirect(url, true);
        },   

这样,我用我的语义对象打开新标签。我在我的模型中注册它。

下一步是与我的按钮链接的方法:

            this._myModel = this._oComponent.getModel("oModelWindow");
            var aWindow = this._myModel.getData().Window;
            aWindow.close();    

我正在加载我打开的标签的窗口。 指令关闭不起作用它写道: “脚本只能关闭它打开的窗口。”

我在 CrossApplicationNavigation 中的理解是它打开了一个新选项卡并使用 sap.m.URLHelper.redirect(url, true); 进行重定向; 当前屏幕在调用新屏幕之前是否知道它打开了哪个页面? 而且这种方式有没有手动关闭的方法?

【问题讨论】:

    标签: sapui5 cross-application


    【解决方案1】:

    我找到了以下解决方案: 打开 crossApplicationnavigation 时,我将打开的选项卡放在内存中:

                var oExtUi = oEvent.getSource().getText();
                var hash = oCrossAppNavigator.hrefForExternal({
                    target: {
                        semanticObject: "ZSIMM_PDL",
                        action: "display"
                    },
                    params: {
                        "UtilitiesPDL": oExtUi
                    }
                });
                var url = window.location.href.split("#")[0] + hash;
                this._oComponent = sap.ui.component(sap.ui.core.Component.getOwnerIdFor(this.getView()));
                this._myModel = this._oComponent.getModel("oModelWindow");
                var aWindow = this._myModel.getData().Windows;
                aWindow.push(window.open(url, "_blank"));
                this._myModel.setProperty("/Windows", aWindow);
    

    在按钮方法中,我记得所有选项卡并以这种方式关闭它们:

                this._oComponent = sap.ui.component(sap.ui.core.Component.getOwnerIdFor(this.getView()));
                this._myModel = this._oComponent.getModel("oModelWindow");
                //then you can iterate over them and close them all like this:
                var oWindow = this._myModel.getData().Windows;
    
                for (var i = 0; i < oWindow.length; i++) {
                    oWindow[i].close();
                }
    

    单击按钮时,所有其他选项卡都将关闭。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-10-04
      • 1970-01-01
      • 2010-09-27
      • 2020-12-26
      • 1970-01-01
      • 2013-12-15
      • 2020-02-19
      • 2021-12-23
      相关资源
      最近更新 更多