0
votes

I have a bigger SAPUI5 application with multiple pages. If user navigates through all these pages, they will reside in memory of course.

Now I have the problem that some of these pages have a complex context with several bindings to an ODataModel. That leads to the problem that a .refresh() call on the underlying ODataModel take some time.

Because: all known bindings will be reloaded (also from pages not currently shown)

Now I am searching for a better solution to refresh the ODataModel.

The refresh must be done because sometimes a client action triggers the server to updates multiple data (in different models!).

Further information (Edit)

I am using multiple ODataModels in my application and they are created in the Component.js (as suggested in the Best practice chapter of the SDK documentation). Navigating through the pages will increase the cached data in the ODataModel. Calling a .refresh() seems to reload all cached data (still used or not). According to the first reply it is possible to refresh one binding but how to refresh all bindings of a given view/page with multiple models?

Would it be the right way to set multiple instances of the ODataModel for each view? And just call the .refresh() method there? But also on this scenario the locally cached data will increase over time?

Any ideas welcome :)

3

3 Answers

3
votes

You can access the binding of a specific UI control and call refresh there. This should just process this specific binding.

0
votes

My first hint would be to use the v2 OData Model (sap.ui.model.odata.v2.ODataModel), as it uses the Batch Mode by default.

Moreover, when it performs updates, it refreshes all bindings of entities that have been updated automatically so you should not need to refresh the whole model at all.

0
votes

For me it worked to just re-bind that binding on a specific element in the view as I did earlier to create it at all.

We had an update-problem after another update call had side effects on the information in question, but a refresh on the binding of the elemnt itself did not solve that. I guess there were no local changes to that path in the model, so there was nothing to refresh. But on server-side there where updates the model/Cache didn't know about. Rebinding made my day, and also only the one necessary call to the servcie was made.