用于在页面之间导航的忙碌指示器



我对SAPUI5很陌生,仍然学到了很多东西。 实际上,我正在尝试在两个不同的视图之间导航时设置一个繁忙的对话。

我已经定义了 busy对话框,并在点击导航按钮后将其设置为按事件。对话框正在显示,但我不太确定有关关闭事件的处理。我以为onMatchedRoute可以帮助我,但对话框没有关闭。我的第一页控制器如下所示:

sap.ui.define([
"sap/ui/core/mvc/Controller",
"sap/ui/core/format/NumberFormat",
"sap/m/BusyDialog"
], function(Controller, NumberFormat) {
"use strict";
var BusyDialogGlobal;
return Controller.extend("sap.turbo.ma.mc.controller.region.americas.AmFinance", {
onInit: function() {
BusyDialogGlobal = new sap.m.BusyDialog("GlobalBusyDialog",{title:"Please wait. . . "});
onHomePress: function() {
var oRouter = this.getOwnerComponent().getRouter();
oRouter.navTo("home");
var getDialog = sap.ui.getCore().byId("GlobalBusyDialog");  
getDialog.open();  

这部分正在工作。我不确定在加载第二个页面/视图后关闭繁忙对话框的进一步流程处理部分。也许有人有一个小片段或例子可以帮助我?

您没有在全局范围内定义"BusyDialogGlobal"。它是在此视图的控制器作用域中定义的。因此,在您的第二个视图中,您可能无法访问它。

您可以在此处执行两种方法(按我认为更好的顺序):

选项 1

构建扩展自定义"基本控制器"的所有控制器,这样您就可以从所有子控制器访问其功能。为此,请创建一个普通的控制器,像您所做的那样从 sap/ui/core/mvc/Controller 扩展。例如,将其称为"基本控制器"并将其保存在控制器文件夹中。然后创建从基本控制器扩展的所有视图控制器。像这样:

sap.ui.define([
"sap/ui/core/mvc/Controller"
], function (Controller) {
"use strict";
return Controller.extend("mynamespace.controller.BaseController", {
onInit: function(){
this.BusyDialogGlobal = new sap.m.BusyDialog("GlobalBusyDialog",{title:"Please wait. . . "});
},
presentBusyDialog(){
this.BusyDialogGlobal.open()
}
dismissBusyDialog(){
this.BusyDialogGlobal.close()
}
}
});

那么在你的视图中1.controller.js:

sap.ui.define([
"mynamespace/controller/BaseController"
], function (BaseController) {
"use strict";
return BaseController.extend("mynamespace.controller.View1", {
onNavigate: function(){
//Do your navigation logic here
//...
this.presentBusyDialog();
}
}
});

在您的 View2.Controller 中.js

sap.ui.define([
"mynamespace/controller/BaseController"
], function (BaseController) {
"use strict";
return BaseController.extend("mynamespace.controller.View2", {
onInit: function(){
this.dismissBusyDialog();
}
}
});

选项 2

更简单但不那么优雅,只需在组件作用域中实例化 busyDialog,并在需要时从该作用域检索它。

要从视图控制器实例化它:

this.getOwnerComponent().BusyDialogGlobal = new sap.m.BusyDialog("GlobalBusyDialog",{title:"Please wait. . . "});

要在需要时从任何视图控制器打开它:

this.getOwnerComponent().BusyDialogGlobal.open()

要在需要时从任何视图控制器关闭它:

this.getOwnerComponent().BusyDialogGlobal.close()

最新更新