Vous êtes sur la page 1sur 3

loio

68b9644a253741e8a4b9e4279a35c247
view on: demo kit nightly build | demo kit latest release

Data Binding
You use data binding to bind UI elements to data sources to keep the data in sync and allow
data editing on the UI.

• Views
• Models
• Resource Bundles
OpenUI5 follows the “Model View Controller” (MVC) paradigm, which means that we
clearly separate data sources (model), UI (view), and application logic (controller) from
each other. Data binding defines how models and views communicate with each other.
Depending on which external data source you use, you can choose between different model
types to represent it. OpenUI5 supports OData V4 (with restrictions), OData V2, JSON, and
XML models.
There are also internal data sources that are defined in the app for specific purposes. For
those, an app contains the following models:
• The resource model is used to communication with the resource bundle that contains
translatable texts in multiple languages

• The device model is provided by the framework and defines device-specific settings
• View models can be, for example, JSON models that communicate with a
corresponding JSON object. JSON data can also be edited in the app, but they are not
stored - as soon as you refresh the browser or restart the app, the changes are reset.

Most of the models are client-side models. This means that all data is initially loaded to the
model when the app is started. All actions performed on the data are only executed on the
client, and only sent back to the data source when this is triggered by the app. Client-side
models are therefore only recommended for small data sets.
The OData models (V2 and V4) are server-side models, which means that data is only
requested on demand from the back end. Filtering, sorting, and paging actions are
performed on the server. This means, for example, that you don’t have to load a complete
table on the UI to be able to sort the entries.
In the view, you bind data by specifying the binding path for a control. You can use data
types and formatters to validate and format the data on the UI.
Note: To learn more about data binding use the tutorial: Data Binding

Binding Modes: One-time Binding, One-way Binding, and Two-way Binding


The binding mode defines how the data sources are bound. OpenUI5 provides the following
binding modes:
• 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 binding means a binding from the model to the view and from the view to
the model, changes in the model and in the view fire events that automatically trigger
updates all corresponding bindings and the view and model

• One-time binding means from model to view once.

The following table shows which binding modes the respective binding models support:

Model One-time One-way Two-way


OData V4 model (default)
OData V2 model (default)
ODataMetaModel V4 (default)
ODataMetaModel (default)
JSON model (default)
XML model (default)
Resource model (default)

For more information, see API Reference: sap.ui.model.BindingMode.

Vous aimerez peut-être aussi