on 09-22-2016 4:00 PM
Hi,
I am trying to display a view upon the login authentication post the button click .
Login.controller.js
sap.ui.define([
"sap/ui/core/mvc/Controller",
"sap/m/MessageToast",
"sap/ui/model/json/JSONModel"
], function (Controller, MessageToast, JSONModel) {
"use strict";
return Controller.extend("n_cloudonvoice.controller.Login", {
actLogin: function () {
var oRouter = sap.ui.core.UIComponent.getRouterFor(this); ///////////////// Router navigation Work well Here which I dont want /////////////
oRouter.navTo("Campaign");
var sURL = "/destinations/cloudonvoice?method=checkLoginForSap&user=" + this.byId("inpLogin").getValue() +
"&pass=" + this.byId("inpPWD").getValue(); // compile URL to call
var oModel = new sap.ui.model.json.JSONModel();
oModel.loadData(sURL,"",true);
oModel.attachRequestCompleted(function() {
var name = oModel.getProperty("/User/0/name");
MessageToast.show("Welcome "+name +" !!! ");
var oStorage = jQuery.sap.storage(jQuery.sap.storage.Type.local);
oStorage.put("cloudonvoice_authdata", oModel);
var oRouter = sap.ui.core.UIComponent.getRouterFor(this); ///////////////// Router navigation doesnt Work Here which I want /////////////
oRouter.navTo("Campaign");
});
}
});
});
If someone can guide me where I am going wrong .
Plz suggest.
Rg
check if this helps
var that=this;
oModel.attachRequestCompleted(function() {
var name = oModel.getProperty("/User/0/name");
MessageToast.show("Welcome "+name +" !!! ");
var oStorage = jQuery.sap.storage(jQuery.sap.storage.Type.local);
oStorage.put("cloudonvoice_authdata", oModel);
var oRouter = sap.ui.core.UIComponent.getRouterFor(that); ///////////////// Router navigation doesnt Work Here which I want /////////////
oRouter.navTo("Campaign");
});
}
});
});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.