cancel
Showing results for 
Search instead for 
Did you mean: 

sapui5 OData Model Binding Mode support

former_member182048
Active Contributor
0 Kudos

I am wondering if in future releases of sapui5 whether Two Way binding be supported for OData Model Binding.

In the currently available version of the UI Development Kit for HTML5 the following modes are supported

ModelOne WayTwo WayOne Time
Resource Model  -     - X
JSON Model  X     X X
XML Model  X     X X
OData Model  X     - X

  • One Way —> The model implementation supports one way binding which means from model to view (value changes in the model will update all corresponding bindings and the view).
  • Two Way —> The model implementation supports two way binding which means from model to view and from view to model (value changes in the model and in the view will update all corresponding bindings and the view, respective model).
  • One Time —> The model implementation supports one time binding which means from model to view once.

Will "Two Way" binding be supported for OData Model?

If the answer is yes, will we be able to use the SAPData Annotations to change the default bind behaviour of individual controls?

I am thinking this could be done either by property

eg  editable = sap:updatable

or by formatter or mode

// propertyname, formatter function, binding mode

// bindValue(sPath, fnFormatter?, sMode?)

oText.bindValue("firstName",null, sap.ui.model.BindingMode.OneWay)

Cheers

JSP

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member182294
Active Contributor
0 Kudos

Hi JSP,

In my view the OData Model may not support two way binding. The logic behind my comment is; OData model binding is based on Query operation type. So for READ and QUERY we will use HTTP GET, similarly POST for Create records and etc.

We cannot distinguish the operations based on URI as the URI is common for all operations. So we need to explicitly mention the type of operation we are going to perform on the URI by  mentioning method type.

The REST service has certain patters to follow, these become restrictions for the Two way binding. For example the POST method which intern calls Create operation requires all the parameters to be passed irrespective of usage. So we might need to pass additional parameters to POST which may not be in GET. And also we need to pass the X-CSRF-Token along with all update operations.

And as of now the OData Model class sap.ui.model.odata.ODataModel  is not supporting with update operations.

This is my understanding on why OData model does not support two way binding.

Thanks

Abhilash

former_member182048
Active Contributor
0 Kudos

Hi Abhilash

I am not sure I am following your logic.

There are a few client side frameworks which currently have controls that do support two-way OData Model Binding, some of them appear to be Ajax based.  I am yet to see one which uses Datajs the OData library behind SAPUI5, I am hoping this is only a matter of time.

Cheers

JSP

former_member182294
Active Contributor
0 Kudos

Hi JSP,

That's really interesting to know. I have used datajs OData library but I was able to communicate one way only. Please let me know if you get any success with that.

Thanks for correcting me.

Regards

Abhilash

former_member182048
Active Contributor
0 Kudos

UPDATE:

Found a javascript library which does two-way OData binding - http://jaydata.org/   It is similar to SAPUI5 in that it uses the JQuery and Datajs libraries and declarative binding (knockoutjs). It differs in the way it creates concrete types for the models.

former_member182294
Active Contributor
0 Kudos

Thanks for the update. I will explore further.