cancel
Showing results for 
Search instead for 
Did you mean: 

OData Context Binding undefined for Odata v4 service

0 Kudos
391

Hello All,

I am new to UI5 and still exploring.

What i have done so far:

-> Create a DB schema

-> Created a OData V4 using Java SDK - which can perform CRUD operation.

-> Created desitination for the Odata service

-> I have tested it working by creating a demo view with table and displays all the items with item aggregation - list binding

Requirement:

-> My actual requirement is to create a UI5 application with a simple view with 4 input fields and a save button.

-> When i click on Save it should perform the binding and save the data in the backend database.

-> Below is the code i have written so far for the controller but it is not working. Can someone suggest on what should be code to make the save button working.

sap.ui.define([
	"sap/ui/core/mvc/Controller",
	"book/BookAdd/utils/utils",
	"sap/ui/model/json/JSONModel"
], function(Controller, utils, JSONModel) {
	"use strict";


	return Controller.extend("book.BookAdd.controller.Add", {
		onInit: function() {
			var oModel = new JSONModel({
				data: {
					"bookId": parseInt(utils.generateRandomNumber(100, 9999)),
					"bookName": "",
					"isbn": "",
					"price": undefined,
					"priceCurrency": utils.getDefaultCurrencyCode(),
					"authorName": ""


				}
			});
			this.getView().setModel(oModel, 'addModel');
			


		},
		


		onSave: function() {
			var oView = this.getView();
			var self = this;
			var oBinding = this.oView.byId("simpleFormChange").getBinding({path: "/Book"});
			var oDModel = oView.getModel();
			var oContext = oBinding.create(oDModel.oData.data);
			
		},


		onCancel: function() {


		}


	});
});

Accepted Solutions (0)

Answers (0)