Quantcast
Channel: SCN : Popular Discussions - SAP NetWeaver Gateway Developer Center
Viewing all articles
Browse latest Browse all 1657

odata binding

$
0
0

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:

 

<feedxmlns="http://www.w3.org/2005/Atom"xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"xml:base="http://localhost:8080/serveris/SERVERIS.svc/">
<scriptid="tinyhippos-injected"/>

<id>http://localhost:8080/serveris/SERVERIS.svc/Users</id>

<titletype="text">Users</title>

<updated>2014-05-27T18:07:01.403+03:00</updated>

<author>
<name/>

</author>

<linkhref="Users"rel="self"title="Users"/>

<entry>

<titletype="text">Users</title>

<updated>2014-05-27T18:07:01.404+03:00</updated>

<categoryterm="serveris.User"scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>

<linkhref="Users(0)"rel="edit"title="User"/>

<linkhref="Users(0)/TasklistDetails"rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/TasklistDetails"title="TasklistDetails"type="application/atom+xml;type=feed"/>

<contenttype="application/xml">
<m:properties>
<d:Login>jonas</d:Login>

<d:Passw>saugus</d:Passw>

<d:UserId>0</d:UserId>

</m:properties>

</content>

</entry>

<entry>

<titletype="text">Users</title>

<updated>2014-05-27T18:07:01.405+03:00</updated>

<categoryterm="serveris.User"scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>

<linkhref="Users(1)"rel="edit"title="User"/>

<linkhref="Users(1)/TasklistDetails"rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/TasklistDetails"title="TasklistDetails"type="application/atom+xml;type=feed"/>

<contenttype="application/xml">
<m:properties>
<d:Login>petras</d:Login>

<d:Passw>pass</d:Passw>

<d:UserId>1</d:UserId>

</m:properties>

</content>

</entry>

</feed>


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


Viewing all articles
Browse latest Browse all 1657

Trending Articles



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