The common way to make a data binding in UI5 is via this.getView().getModel()
:
const wantedModel = this.getView().getModel("wantedModel");
this.getView().setModel(wantedModel);
However, it's possible to perform a binding via this.getOwnerComponent().getModel()
as well:
const wantedModel = this.getOwnerComponent().getModel("wantedModel");
this.getView().setModel(wantedModel);
In my case, the data model is defined in manifest.json, and I have two options to retrieve a model for a binding:
- via
getView()
inonBeforeRendering()
, which is called every time a view is rendered - via
getOwnerComponent()
inonInit()
, which is called only once.
To avoid setting a model every time a view is rendered, I consider using the second approach. What are the possible advantages/drawbacks, primarily performance-related, of getting a model via getOwnerComponent()
over getView()
?