Small SAP Talk. Protecting Against Data Loss in a SAPUI5 Application
Small SAP Talk. Protecting Against Data Loss in a SAPUI5 Application
Let’s imagine a simple scenario: a user starts working in a SAPUI5 application, enters various data into form fields, but then—for some reason—presses the F5 key on the keyboard or clicks one of the navigation controls within the application. As a result, they are redirected to the SAP Fiori Launchpad homepage. For example:
To address this issue, the vendor suggests using the setDirtyFlag
function, which is part of the sap.ushell
namespace.
See:Implementing Data Loss Protection
Use the methods of the Container API to mark a page as “dirty” (i.e., containing unsaved changes) and activate the data loss protection mechanism when appropriate. Set the dirty flag totrue
whenever there are unsaved changes in the application that could result in data loss.
After adding the appropriate checks, the application will respond to attempts to return to the Launchpad homepage or force a browser page refresh. For example:
Magic, no less.
For more information about the "Small SAP Talk" series, refer to the following note:
See: Small SAP Talk