cancel
Showing results for 
Search instead for 
Did you mean: 

Question on UI5 router

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi Naik,

u are right, I found this point as well, changed the pattern in manifest.jaon n it works fine now!

thanks for sharing!

Magina

Former Member
0 Kudos

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