Quantcast
Channel: SCN: Message List - SAPUI5 Developer Center
Viewing all articles
Browse latest Browse all 8124

Navigate to other page in controller.onInit

$
0
0

Hi there,

 

I want to check on each and every page of my app, if the login cookie has been set and if not, I would like to navigate to the login page. I therefore implemented the onInit function of the controller:

 

 

onInit: function () {       // if user is not logged in, no cookie is set       if (this.getCookie("myCookie") == null) {       var app = sap.ui.getCore().byId("appTools");       app.to("js.Login");       }  },

Both views have been added to the app like this:

 

// instantiate the View
 var loginView = sap.ui.view("js.Login", {type:sap.ui.core.mvc.ViewType.JS, viewName:"js.Login"});
 // add page to the App
 app.addPage(loginView);

 

The code is processed but unfortunately, nothing happens, at least, no navigation to js.Login.

 

What am I doing wrong here?

 

Thanks


Viewing all articles
Browse latest Browse all 8124

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>