Skip to Content
0

Problem getting past parameters with routing

Mar 21, 2017 at 07:46 PM

71

avatar image

Hi, i hope can you help me,

I am trying to get past parameters with routing, but when using,

in the onInit method, getting router and attach method "onRoutePatternMatched"

 onRoutePatternMatched: function(oEvent){                
        var parameters = oEvent.getParameters();
        alert(JSON.stringify(parameters));
}

Getting

{
"name":"detailBooking",
"arguments":{},
"config":
       {
         "routerClass":"sap.m.routing.Router",
         "viewType":"XML",
         "viewPath":"adois.ui.view",
         "controlId":"appMain",
         "controlAggregation":"pages",
         "transition":"slide",
         "bypassed":{"target":"notFound"},
         "_async":false,
         "targetParent":"__xmlview0",
         "pattern":"DetailBooking",
         "name":"detailBooking",
         "target":"DetailBooking"
       }
}

As you can see, you are not getting anything in arguments.

from view send data to router "detailBooking"

I am using this method to send the data to the route,

onNavDetailBooking: function(oEvent){
        this.getRouter().navTo("detailBooking",{
              data : oEvent.getSource().getBindingContext().getObject()
        });
}

I hope you can give me some suggestions, thanks in advance.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Seungchul Yang Mar 22, 2017 at 01:21 AM
0

Please paste routing configruation code of your manifest.json.

A pattern of 'detailBooking' should include a argument.

	"routes": [
				{
					"pattern": "",
					"name": "master",
					"target": [
						"object",
						"master"
					]
				},
				{
					"pattern": "detailBooking/{data}",
					"name": "detailBooking",
					"target": [
						"master",
						"object"
					]
				}
			],
Show 2 Share
10 |10000 characters needed characters left characters exceeded

I do not want to change the pattern of my url, I simply want to pass data to the other view, is it possible without having to change the pattern?

0

There is no way to pass a data to another view with routing without modifying a pattern, I think.

Check below link

https://sapui5.hana.ondemand.com/sdk/index.html#docs/guide/2366345a94f64ec1a80f9d9ce50a59ef.html

0
Jun Wu Mar 22, 2017 at 04:15 AM
0

for onRoutePatternMatched, is it triggered by onNavDetailBooking?

if it is not triggered by that, you probably will have nothing.

Show 4 Share
10 |10000 characters needed characters left characters exceeded

What do you mean by

"is it triggered by onNavDetailBooking"

Could you give me an example code please?

0
onNavDetailBooking:function(oEvent){
        this.getRouter().navTo("detailBooking",{data: oEvent.getSource().getBindingContext().getObject()});}


this will trigger the navigation, and onRoutePatternMatched this will be called.
in this case, you will have the data(I assume:))

onRoutePatternMatched may also be invoked in initial page load. in that case, you may have no data.
0

The navigation if it activates, I am able to navigate to the route, but it does not obtain any data

0

show me the route?

0