Skip to Content
avatar image
Former Member

Question on UI5 router

Dear expert,

I saw the demo sap.ui.demo.tdg using the router to  transport parameters:

var bReplace = jQuery.device.is.phone ? false : true; this.getRouter().navTo("product", { from: "master", product: oItem.getBindingContext().getPath().substr(1), tab: this.sTab || "supplier" }, bReplace);

I used the similar code in my App:

sap.ui.core.UIComponent.getRouterFor(this).navTo( "Map",{from: "Detail", latitude: latitude, contextPath: cPath, longitude: longitude}, true

);

however I tried to get it in another view:

sap.ui.core.UIComponent.getRouterFor(this).attachRouteMatched(this.test, this);

test: function(oEvent){ var oParameters = oEvent.getParameters(); this.latitude = oEvent.getParameter("arguments").latitude; },

the parameters of arguments only contain with contextPath, the other value like latitude/longitude could not get.

I didn't know what is the reason, my current UI5 version is 1.24.1.

Thanks,

Dylan

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Dec 08, 2015 at 01:26 PM

    Hi Dylan,

    You have to define the proper pattern in your component.

    Consider this example.

    Master controller

    var oRouter = sap.ui.core.UIComponent.getRouterFor(this);

    var splits = evt.getParameter("listItem").getBindingContext().sPath.split("'");

    var context = {

        parameter1: splits[1],

        bindingContext: splits[3]

    };

    oRouter.navTo("Detail", context);

    }

    Detail Controller

      oRouter.attachRouteMatched(function(oEvent) {

            if (oEvent.getParameter("name") !== "Detail") {

                return;

            }

            var path = "/Eset(ZId='" + oEvent.getParameter("arguments").parameter1+ "',WId='" + oEvent.getParameter("arguments").bindingContext + "')";

            this.getView().bindContext(path);

        }, this);

    Now the component/Router code for the pattern which would be appended to the url

       {

                  viewType: "XML",

                  pattern: "{dino}/{bindingContext}",

                  targetControl: "mysplitapp--splitapp",

                  name: "Detail",

                  viewPath: "sap.myapp.view",

                  view: "Detail",

                  targetAggregation: "detailPages",

              }

    You could try defining

    pattern: "{from}/{latitude}/{longitude}/{contextPath}"

    Hope this helps!

    Regards,
    Naren L  Naik

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 01, 2015 at 09:39 AM

    hi, I got the some error, asking for this point too!

    Add comment
    10|10000 characters needed characters exceeded