Quantcast
Channel: SCN : All Content - SAP for Mobile
Viewing all articles
Browse latest Browse all 6147

Passing input to a oData service

$
0
0

Hi,

 

 

    I am trying to develop a simple mobile application using sapui5. In this application I have 2 sap.m.Input fields to enter two numbers.

These two numbers are then passed to oData service,this odata service intern perfoms calculations over those two inputs for e.g., addition

and returns the result back to the app.

My controller code is as follows:

 

 

calcu:function(n1C,n2C){

          var oModel=new sap.ui.model.odata.ODataModel("proxy/sap/opu/odata/sap/ZMY_EXPERIMENT_SRV",false,"uname","password");

              oModel.setDefaultBindingMode(sap.ui.model.BindingMode.TwoWay);

                    sap.ui.getCore().setModel(oModel);

          n1C.bindProperty("value","/A");

          n2C.bindProperty("value","/B");

          oModel.attachRejectChange(this,function(oEvent){

              alert("You are already editing another Entry! Please submit or reject your pending changes!");

          });

          oModel.submitChanges(function(){alert("successfull");},function(){alert("not successfull");});

 

          alert(oModel.getProperty("/A"));

 

   alert(oModel.getProperty("/B"));

 

          alert(oModel.getProperty("/Res"));

 

          }

 

 

 

 

n1C,n2C are Input fields,and "/A" ,"/B" ,"/Res" are properties. On click of a "addition" button "calcu" function is called.

As Binding mode is set to "TwoWay",the changes made in textfield should update in a model .

But on execution of the app it is showing "undefined" in alert box.

There is no error in google chrome's developers tool and able to see XHR file.

 

Could you please let me know where i am going wrong.

 

Thank you,

Vijay.


Viewing all articles
Browse latest Browse all 6147

Trending Articles



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