SAP Ui5-data Model

Source: Internet
Author: User

1. JSON Model

{company    : {        "treefish Inc",        info: {            3,        },        contacts: [            {                 "Barbara",                "873"            },            {                "Gerry",                "734"            },            {                "Susan",                "275"            }        ]}    }

Access path:

/company/name/company/info/Employees/company/contacts 

2. OData Model

Sap.ui.model.odata.ODataModel is not recommended, use Sap.ui.model.odata.v2.ODataModel instead.

Declaring the OData Model

1 var New Sap.ui.model.odata.v2.ODataModel ("http://services.odata.org/Northwind/Northwind.svc/"); 2 var New Sap.ui.model.odata.v2.ODataModel ({serviceurl: "Http://services.odata.org/Northwind/Northwind.svc"}) ;

Get OData Service metadata:

var ometadata = Omodel.getservicemetadata ();

Additional information can be added when requesting OData service data:

1 varOmodel =NewSap.ui.model.odata.v2.ODataModel ({2Serviceurl: "Http://services.odata.org/Northwind/Northwind.svc",    3 serviceurlparams: {4Myparam: "Value1",5MYPARAM2: "value2"6     },7 metadataurlparams: {8Myparam: "Value1",9MYPARAM2: "value2"Ten     } One});

The service data is accessed when it is requested

"Http://myserver/MyService.svc/?myParam=value&myParam2=value2" This path,
The same is true when requesting metadata: (TODO)

Get Data:

1 omodel.getdata ("/customer (' ALFKI ')"); 2 omodel.getproperty ("/customer (' ALFKI ')/address");
varOData ={ProductId:999, ProductName:"MyProduct"}//POSTOmodel.create ("/products", OData, {success:mysuccesshandler, error:myerrorhandler});//GETOmodel.read ("/products (999)", {success:mysuccesshandler, error:myerrorhandler});//PUTvarOData ={ProductId:999, ProductName:"Myproductupdated"}omodel.update ("/products (999)", OData, {success:mysuccesshandler, error:myerrorhandler});//DELETEOmodel.Delete("/products (999)", {Success:mysuccesshandler, error:myerrorhandler});

Omodel automatically refresh after the change is complete

Omodel.setrefreshafterchange (FALSE); Turn off automatic refresh

Todo





3. XML Model

SAP Ui5-data Model

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.