简体   繁体   English

导航到另一个xmlview的sapui5弹出窗口

[英]sapui5 popup navigating to another xmlview

I am extending an fiori app and have replaced a view and placed a popup. 我正在扩展一个fiori应用程序,并替换了一个视图并放置了一个弹出窗口。 Now my requirement is when I click the close button in the popup I want to open an xmlview. 现在我的要求是,当我单击弹出窗口中的关闭按钮时,我想打开一个xmlview。

code.
sap.m.MessageBox.error( "Error Message - some error", 
{ icon: sap.m.MessageBox.Icon.ERROR, title: "Confirmation Error", onClose: function (oAction) { 
 this.router = sap.ui.core.UIComponent.getRouterFor(this); 
this.router.navTo("customview"); } } );

can some one pls advise on the error I am getting. 可以请一些建议我得到的错误。

'navTo' of undefined

manifest.json 的manifest.json

"routing": {
   "config": {
    "routerClass": "sap.m.routing.Router",
    "viewType": "XML",
    "viewPath": "publicservices.her.myApp.myAppExtension.view",
    "controlId": "app",
    "controlAggregation": "pages",
    "async": true
   },
   "routes": [{
    "pattern": "",
    "name": "customView",
    "target": "customView"
   }
   ],
   "targets": {

    "customView": {
    "viewName": "customView",
     "viewId": "customView"
    }
   }
  }
 }

There are a few things I want you to check in your project in order for your router to be defined. 为了让您定义路由器,我希望您签入一些项目。 I added an example below. 我在下面添加了一个示例。

Hope this helps. 希望这可以帮助。

Component 零件

    init: function() {
        UIComponent.prototype.init.apply(this, arguments);
        this.setModel(models.createDeviceModel(), "device");

        // MAKE SURE YOUR ROUTER IS INITIALISED HERE
        this.getRouter().initialize();
    }

Manifest 1 清单1

Make sure you add a controlId and controlAggregations 确保添加了controlId和controlAggregations

    "routing": {
        "config": {
            "routerClass": "sap.m.routing.Router",
            "viewType": "XML",
            "viewPath": "Test.view",
            "controlId": "app",
            "controlAggregation": "pages"
        },

Manifest 2 清单2

    "routes": [{
            "pattern": "",
            "name": "main",
            "target": "main"
        }, {
            "pattern": "side",
            "name": "side", // YOU'LL USE THIS NAME TO NAVIGATE IN THE CONTROLLER
            "target": "side"
        }],
        "targets": {
            "main": {
                "viewName": "Main"
            },
            "side": {
                "viewName": "Side" // ENSURE THIS IS CORRECT (this refers to view: 'Side.view.xml')

            }
        }

View 视图

<App id="app"> <!-- ADD THIS ID TO ALL VIEWS -->
    <pages> <!-- SHOULD HAVE THE SAME VALUE AS CONTROLID IN THE MANIFEST-->
        <Page title="Page 1">
            <content>
                <Button press="onOpenMessageBox" text="Open" />
            </content>
        </Page>
    </pages>
</App>

Controller 调节器

Navigate to route with the name "side" 导航至名称为“ side”的路线

    onOpenMessageBox: function() {
        var that = this; // SET VARIABLE THAT TO THIS
        sap.m.MessageBox.error("Error Message - some error", {
            icon: sap.m.MessageBox.Icon.ERROR,
            title: "Confirmation Error",
            onClose: function(oAction) {
                // CHANGE ALL 'this' TO 'THAT'
                // THIS HAS ANOTHER CONTEXT IN THIS FUNCTION
                that.oRouter = sap.ui.core.UIComponent.getRouterFor(that);
                that.oRouter.navTo("side");
            }
        });
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM