cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

We have a bunch of custom free-style Fiori apps created a few years ago, that contain code like this in the attachPatternMatched method of the router object:

var oElementBinding = this.getView().getElementBinding();
if ( oElementBinding.getBoundContext() ) {
	oElementBinding.refresh(); 
}

This is to ensure if the user navigates away and then back to an Object page, the view's elementBinding gets refreshed from the backend (because view.bindElement( ) does not call the backend if user navigates away then back to the object page).

This has worked fine so far until we upgraded to SAPUI5 1.71.53 (from 1.71.48), and now it doesn't refresh.

We found that if we add the parameter true, it works as before:

oElementBinding.refresh(true); 

Now, I know we should have had the "true" parameter from the start, but why would that make a difference in 1.71.53, and not 48. The parameter is supposed to only matter if the model has not changed, in our cases the model has changed, so the refresh should work even without the parameter.

Would appreciate any recommendations, on what the proper way is to ensure models are updated as user navigates between pages.

Thanks

0 Likes
View Entire Topic
boghyon
Product and Topic Expert
Product and Topic Expert

Assuming the "model" is of type v2.ODataModel, you can ensure that the bound context fetches always the entity from the OData service by calling sap.ui.model.odata.v2.ODataModel#invalidateEntry before bindElement (or bindObject).

See my other answer at "How to refresh previously bound entity every time user visits the page?"

Most of the times, Model#refresh is not required.

RaminS
Active Participant
0 Likes

Thanks a lot, I will try that.

I had already tried unbindElement( ), but it didn't do anything.

Do you have other examples of proper controller logic? I feel like many of us could use more examples, as there are so many different ways of doing things. I've been looking in Github for examples but it's hard to find what youre looking for.

Thanks again.

RaminS
Active Participant
0 Likes

I'm curious, how does this refreshing happen in SAP's List Report template? Do they use invalidateEntry in the object page to make sure it refreshes when user navigates from worklist to Object? And how do they ensure Worklist gets refreshed when the user edits something in the Object page? .... Do they use eventBus subscribe/publish events? How do they ensure models get refreshed at the right time?

.

boghyon
Product and Topic Expert
Product and Topic Expert
0 Likes

ramin.shafai

Templates from SAP Fiori elements (FE) are not really comparable with rather simple freestyle apps since FE implements a number of additional features, such as draft handling, side effects, refreshing in sap-keep-alive, etc., that affect the object page or any other bound elements.

We can see in the current FE V2 source code that invalidateEntry is one of the approaches the Object Page uses to refresh itself unconditionally.

Having to "ensure models get refreshed at the right time" sounds like the application is incorrectly applying changes typically via private properties or unbound model paths. If you need more help, we'd need to look at the application code in a new question.