For a modern fiori-style application in SAPUI5 involving Component and related routing you can always attach a method to your view, which will be called whenever there is a match with the provided route pattern for this view. This route was historically represented in the metadata of the Component class, but since v1.30 it is declared in the manifest.json file.
In the onInit method of your view, you can do:
onInit: function() { this._oRouter = this.getOwnerComponent().getRouter(); this._oRouter.getRoute("yourRouteForThisView").attachPatternMatched(this._onObjectMatched, this); }
So, you have the _onObjectMatched method, which will be called every time you are in sight. Here you can place all of your code here, which must be executed before your view is displayed.
_onObjectMatched: function(oEvent) { var oArgs = oEvent.getParameter("arguments");
You can also use this for your landing page. The first view usually has an empty string "" as a route pattern in manifest .
Kumar
source share