Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
控制器中的sapui5 odata绑定_Odata_Sapui5 - Fatal编程技术网

控制器中的sapui5 odata绑定

控制器中的sapui5 odata绑定,odata,sapui5,Odata,Sapui5,我正在演示MyFiorri应用程序上构建应用程序,使用ODATA绑定数据时遇到问题。我在component.js中定义了odata jQuery.sap.declare("sap.ui.demo.myFiori.Component"); sap.ui.core.UIComponent.extend("sap.ui.demo.myFiori.Component", { createContent : function() { // create root view va

我正在演示MyFiorri应用程序上构建应用程序,使用ODATA绑定数据时遇到问题。我在component.js中定义了odata

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;  
  }  
});  
现在,我需要阅读这些数据:

<feed xmlns="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/">
<script id="tinyhippos-injected"/>
<id>http://localhost:8080/serveris/SERVERIS.svc/Users</id>
<title type="text">Users</title>
<updated>2014-05-27T18:07:01.403+03:00</updated>
<author>
<name/>
</author>
<link href="Users" rel="self" title="Users"/>
<entry>
<id>
http://localhost:8080/serveris/SERVERIS.svc/Users(0)
</id>
<title type="text">Users</title>
<updated>2014-05-27T18:07:01.404+03:00</updated>
<category term="serveris.User" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
<link href="Users(0)" rel="edit" title="User"/>
<link href="Users(0)/TasklistDetails" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/TasklistDetails" title="TasklistDetails"type="application/atom+xml;type=feed"/>
<content type="application/xml">
<m:properties>
<d:Login>jonas</d:Login>
<d:Passw>saugus</d:Passw>
<d:UserId>0</d:UserId>
</m:properties>
</content>
</entry>
<entry>
<id>
http://localhost:8080/serveris/SERVERIS.svc/Users(1)
</id>
<title type="text">Users</title>
<updated>2014-05-27T18:07:01.405+03:00</updated>
<category term="serveris.User" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
<link href="Users(1)" rel="edit" title="User"/>
<link href="Users(1)/TasklistDetails" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/TasklistDetails" title="TasklistDetails"type="application/atom+xml;type=feed"/>
<content type="application/xml">
<m:properties>
<d:Login>petras</d:Login>
<d:Passw>pass</d:Passw>
<d:UserId>1</d:UserId>
</m:properties>
</content>
</entry>
</feed>

我希望我清楚地描述了我的问题。

handleContinue
函数中放置一个调试断点,并尝试查看
sap.ui.getCore().getModel().getData()的日志中显示了什么

如果您能够记录某些内容,请尝试在控制台中以这种方式查看:

  • var theModel=sap.ui.getCore().getModel()
  • model.oData
    查看您得到的输出,然后可以继续

  • 你的控制器到底出了什么问题?尝试获取“authinfo”时模型是否为空?.getData()返回什么?“我希望我清楚地描述了我的问题”--不幸的是,您根本没有定义问题所在..getData返回:Uncaught TypeError:undefined不是一个函数。问题是,我需要读取用户数据并通过匹配输入的值对其进行身份验证。然后它应该像Users(1)/tasklistdetails一样按用户ID打开母版页。如果Ripple正在向OData提要中注入脚本,请尝试禁用。如果您尝试在控制器中将
    this.getCore()
    更改为
    sap.ui.getCore()
    ,我认为这是错误的,因此会抛出未捕获的类型错误。
    <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>  
    
    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");  
      }  
    }  
    });