Wednesday, May 24, 2017

Data Binding

https://help.sap.com/saphelp_uiaddon20/helpdata/en/68/b9644a253741e8a4b9e4279a35c247/content.htm

Sorry! SAP, I am not sure if  you will keep this nice document active, so I am making a copy of it for future reference.


Data Binding

You use data binding to bind two data sources or information sources together to keep them in synch: All changes in one data source are also reflected in the other data source.
For data binding, you need a model and a data binding instance: The model instance holds the data and provides methods to set the data or to retrieve the data from a server. It also provides a method for creating bindings to the data. When this method is called, a data binding instance is created, which contains the binding information and provides an event, which is fired whenever the bound data is changed. An element can listen to this event and update its visualization according to the new data.
The UI usually uses data binding to bind UI controls to the model, which holds the application data, so that the controls are updated automatically whenever application data is changed. Data binding is also used when changes in the control cause updates in the underlying application data, such as data being entered by a user.
The default binding mode for model implementations (if not implemented otherwise) is two-way binding and the supported binding modes by the model are one-way binding, two-way binding and one-time binding. The default binding mode can be changed by the application for each model instance. A model implementation should specify its supported binding modes and set the default binding mode accordingly (e.g. if the model supports only one-way binding the default binding mode should also be set to one-way).
Note
To learn more about data binding use the tutorial: Data Binding
Binding Modes
The binding mode defines how the data sources are bound. The different model implementations require specific binding modes. The resource model, for example, only supports one-time binding, that is, a binding from the model to the view.
SAPUI5 provides the following binding modes:
  • One Way: One-way binding means a binding from the model to the view; value changes in the model update all corresponding bindings and the view
  • Two Way: Two-way binding means a binding from the model to the view and from the view to the model; value changes in the model and in the view update all corresponding bindings and the view and model, respectively
  • One Time: One-time binding means from model to view once.
The following table shows, which binding modes the respective binding models support:
ModelOne-wayTwo-wayOne-time
OData modelX (default)XX
JSON modelXX (default)X
XML modelXX (default)X
Resource model----X
NoteThe following image contains links to more information.
The OData V2 Model enables binding of controls to data from OData services.The sap.ui.model.odata.v4.ODataModel is the model implementation for consuming an OData V4 service.The JSON model can be used to bind controls to JavaScript object data, which is usually serialized in the JSON format.The XML model allows to bind controls to XML data. It is a client-side model intended for small datasets, which are completely available on the client. The XML model does not contain mechanisms for server-based paging or loading of deltas. It supports two-way binding.The resource model is used as a wrapper for resource bundles. In data binding you use the resource model instance, for example, to bind texts of a control to language-dependent resource bundle properties.
The resource model only supports the one-time binding mode because it deals with static texts only.
For more information, see the API Reference for sap.ui.model.BindingMode in the Demo Kit.
Binding Types
SAPUI5 supports three different binding types: Property binding, aggregation binding, and element binding. The binding types are introduced in the following sections.

No comments:

Post a Comment