Hello, this is my first post. I am building app on demo MyFiorri application and I have problem binding data using ODATA. I difined odata in component.js
jQuery.sap.declare("sap.ui.demo.myFiori.Component"); sap.ui.core.UIComponent.extend("sap.ui.demo.myFiori.Component", { createContent : function() { // create root view var oView = sap.ui.view({ id : "app", viewName : "sap.ui.demo.myFiori.view.App", type : "JS", viewData : { component : this } }); // set i18n model var i18nModel = new sap.ui.model.resource.ResourceModel({ bundleUrl : "i18n/messageBundle.properties" }); oView.setModel(i18nModel, "i18n"); // // Using OData model to connect against a real service var url = "http://localhost:8080/serveris/SERVERIS.svc/"; var oModel = new sap.ui.model.odata.ODataModel(url, true, "", ""); oView.setModel(oModel); sap.ui.getCore().setModel(oModel); // set device model var deviceModel = new sap.ui.model.json.JSONModel({ isTouch : sap.ui.Device.support.touch, isNoTouch : !sap.ui.Device.support.touch, isPhone : sap.ui.Device.system.phone, isNoPhone : !sap.ui.Device.system.phone, listMode : sap.ui.Device.system.phone ? "None" : "SingleSelectMaster", listItemType : sap.ui.Device.system.phone ? "Active" : "Inactive" }); deviceModel.setDefaultBindingMode("OneWay"); oView.setModel(deviceModel, "device"); // done return oView; } });
Now, I need to read these data:
I made login.view.xml and login.controller.js in which i want ta access these data
login.view.xml
<core:View controllerName="sap.ui.demo.myFiori.view.login" xmlns="sap.m" xmlns:l="sap.ui.layout" xmlns:core="sap.ui.core" > <Page title="{i18n>LoginIn}"> <VBox class="marginBoxContent" > <items> <Label text="username" /> <Input id="nameInput" type="Text" placeholder="enter username ..." /> <Label text="Pasword" /> <Input id="passwInput" type="Password" placeholder="enter password..." /><Button text="Prisijungti" press="handleContinue" /> </items> </VBox> </Page></core:View>
login.controller.js
jQuery.sap.require("sap.ui.demo.myFiori.util.Formatter"); sap.ui.controller("sap.ui.demo.myFiori.view.login", { handleContinue : function (evt) { // var authinfo = this.getCore().getModel().getData().Users[0]; In this line I should get data var name = this.getView().byId("nameInput").getValue(); var paswd = this.getView().byId("passwInput").getValue(); if (name == "authinfo.login" && paswd == "authinfo.passw") { var context = evt.getSource().getBindingContext(); this.nav.to("Master", context); } else { jQuery.sap.require("sap.m.MessageToast"); sap.m.MessageToast.show("there is no such user or bad login data"); } } });
I hope I clearly described my problem. Thanks in advance