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