You can use the sap-keep-alive feature to ensure that a view persists in the view cache when navigating away from the application in SAP Fiori elements for OData V4.
The feature ensures improved performance when you reload the same view again once you navigate back to the application. For more information, see Keeping SAPUI5 Apps Alive.
If you make changes in an external application that you navigated to, then when you navigate back and reactivate the application view, the changes that you made are reflected without rebinding the control. It means that the application still shows the latest data, but the control is not rebound. This allows the earlier state (scroll position, selections) to be retained.
You can configure the entity sets that you want to refresh. To do so, upon navigating back to the source application from the target application, you can use the manifest configurations described below. SAP Fiori Elements defines default refresh mechanisms when the application configured with the sap-keep-alive parameter is activated again by SAP Fiori launchpad (for example, upon a back navigation following an external navigation).
The following configurations are supported for entity sets:
|
EntitySet1: |
Only <EntitySet1> is to be refreshed |
|
EntitySet2: |
Refresh <EntitySet2> along with all its dependents (navigation property) |
includingDependentsdoesn't mean that data for child navigation entities gets refreshed, even if the UI has no control that is bound to the navigation entity. It only refreshes the data for the child navigation entity, if there is a control in the UI that is bound to the child navigation entity.
Refresh occurs for the entity set of the table that gets triggered from the navigation, while moving back to the source application.
Refresh occurs for the entity set of the table that gets triggered from the navigation, while moving back to the source application. However, you can switch it off or override it by configuring the manifest.json file.
Refresh is not performed by default. You can override the default behavior and refresh specific entity sets using the manifest configuration. You can configure the refresh strategies defined for specific outbound navigation by configuring the manifest.json file.
While navigating back to the source application, if an external navigation is triggered using the navigateExternal API, the refresh strategies of the outbound target that is passed to the API is considered for refreshing the entity set. The entity sets specified in the manifest under refreshStrategyOnAppRestore of that specific outbound configuration are considered for refresh. The refresh mechanism is exactly the same as defined for the external navigation section.
The configuration is specified for each page and the most specific configuration, based on the external navigation that is performed, is considered. The following logic is applied:
-
If there is a configuration specified for the exact semantic object-action that matches the external navigation, then this configuration is used.
-
If no such configuration is found, but if there is a configuration for the same semantic object, then this is used.
-
If this is also not found, then the default configuration of the page level is used (if defined).
Examples of the applied logic are shown in the following sample code:
Manifest configuration for the refresh strategies in
sap-keep-alivemode{ "sap.ui5": { "routing": { "targets": { "SalesOrderManageList": { "type": "Component", "id": "SalesOrderManageList", "name": "sap.fe.templates.ListReport", "options": { "settings": { ... "refreshStrategyOnAppRestore": { "defaultBehavior": { "SalesOrderManage": "self" } } } } }, "SalesOrderManageObjectPage": { "options": { "settings": { ... "refreshStrategyOnAppRestore": { "intents": { "v4Freestyle": { // This block is considered if the block above is NOT matched but the external navigation before we landed on this page only matches the Semantic Object specified here and NOT the action part "SalesOrderItem": "includingDependents" }, "v4Freestyle-Inbound": { // This block is considered if the external navigation before we landed on this page matches exactly the Semantic Object-Action specified here "SalesOrderItem": "includingDependents" } }, "defaultBehavior": { // This block is used if the external navigation before we landed on this page does NOT match the above blocks. This can happen for navigations where the Semantic Object is different from what is specified above. "SalesOrderManage/_Item": "includingDependents" } } } } } } } } }
Applications can choose to switch off the default refresh behavior that happens when an external chevron navigation is triggered. To achieve this, keep an empty block within the manifest configuration as shown in the following sample code:
Switching off the default refresh behavior
"refreshStrategyOnAppRestore": { "intents": { "v4Freestyle-Inbound": { "SalesOrderItem": "includingDependents" // Due to this override, only SalesOrderItem and dependents are refreshed for V4FreeStyle-Inbound So-Action external navigation }, "v4Freestyle": {} // Due to this override, for all other intents from V4FreeStyle SO other than Inbound, no refresh is done (including when going to such a target through chevron navigation which normally triggers a default refresh of the table) } }
This does not affect the default refresh behavior of the table entity set when external navigation is triggered for a Create case.
The refresh mechanism explained earlier is only for refreshing the data seen on that page after navigating back from an external target. After the user navigates back from the external target, if the user then navigates forward through the standard internal navigation provided by SAP Fiori elements (for example, to a detail page), a data request is always sent to the back end – irrespective of the configuration given above. For back navigation within the app (internal navigation), the refresh is based on the refresh strategy for the page from where the external navigation was triggered.
When specifying an entity set, application developers must note the following:
Begin with a forward slash ("/") if the entity is a containment-based entity (a parameterized entity) and if you need to specify the full path of the resulting entity ("/Customer/Set") in the same manner as specified with the
"contextPath"manifest property. For more information, see the section Supporting Parameterized Entities in Configuring Filter Bars.If it is not a containment scenario/parameterized entity but a regular entity set, then the slash is not required at the beginning (
"SalesOrderItem").
For information about SAP Fiori elements for OData V2, see Refresh Entity Sets in sap-keep-alive Mode.
Related Information
Refresh Dataset for Back Navigation when sap-keep-alive is Set to True