Warm tip: This article is reproduced from serverfault.com, please click

How to call HTML view from XML view in sapui5

发布于 2017-08-04 13:22:48

I am designing a SAP UI5 Application which has 2 XML and 1 HTML view.I want to navigate to a HTML View from XML view on click of a button. How can i set routing for this.

Below code is not working:

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

    },

    routes: [{
            "pattern": "",
            "name": "View1",
            "viewPath": "executive.WebContent.view",
            "viewType": "XML",
            "target": "View1"
        },
        {
            "pattern": "Login",
            "name": "View2",
            "viewPath": "executive.WebContent.view",
            "viewType": "XML",
            "target": "View2"
        },

        {
            "pattern": "Visitor",
            "name": "View3",

            "viewPath": "executive.WebContent.view",
            "viewType": "HTML",
            "target": "View3"


        }
    ],

    targets: {
        "View1": {
            "viewName": "Main"

        },
        "View2": {
            "viewName": "Login"

        },
        "View3": {
            "viewName": "Visitor"

        }
    }

}

Let me know, solution for this.

Questioner
John Smith
Viewed
0
David Vela 2017-08-06 06:05:47

As far as I see you are defining a global type XML in the config part of your routing; this will cause a conflict in your routes.

I tried to do what you are trying to do right now. But, I found an alternative solution. You can have a third XML view and inside the XML you can embed your HTML view. something like this:

<mvc:HTMLView id="nestedViewhtmnl" 
viewName="executive.WebContent.view"
controller="executive.controller.xx" type="HTML"></mvc:HTMLView>

I hope this helps you =)