Reputation: 1382
I would like reload the same path using the routing;
In onInit
I have the routeMatched function where I have the calls to the server:
this.router.attachRoutePatternMatched(this._handleRouteMatched, this);
this is the call:
var idProduct= "p1"
this.router.navTo("product", {
id_product: idProduct
});
the url path is : .../index.html#/product/p1
The first time that I call the navTo
function _handleRouteMatched
is launched. Right!
But then, if in the same path I want (by a button) reload the same product I would like do it by navTo
function but in this 2nd case the function _handleRouteMatched
is not launched.
Wath is the right way to solve the my problem? I don't like write the content of the _handleRouteMatched in the logic when I press the button. I would like pass always across the router
Upvotes: 0
Views: 2199
Reputation: 2566
The router in ui5 is smart enough to detect that your navTo() is going to the current route with the current args. It does not make any sense for the router to trigger the routing in such cases, because you are already there. If you want to reload/refresh the same product again, then you should get a reference to the corresponding binding and call refresh() on that binding. In case you are using an ODataModel this should refetch the data from the server automatically. For more information see https://sapui5.hana.ondemand.com/#docs/api/symbols/sap.ui.model.Binding.html#refresh
Upvotes: 2