on 12-26-2014 3:39 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi, I got the some error, asking for this point too!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.