Wait Until OData Request Completed

Viewed 390

I have a requirement to oData service inside onExit hook method. I have written below code but unfortunately oData service is not getting called as view is destroyed immediately . Is there any way to add wait or delay the destroy of view until oData read request is complete ?

window.addEventListener("beforeunload", (event) => { this.fnUnlockGremienVersion();

         var s;
            event = event || window.event;
            if (this._PreviousGreVersion) {
             s = "Your most recent changes are still being saved. " +
                    "If you close the window now, they may not be saved.";
                event.returnValue = s;
                return s;                    
            }
         
        });
1 Answers

UI5 has no support for such a workflow and it's not only "UI5", in fact webpages can't block/trap a user within a page for various reasons. Just remember the annoying un-closable webpages from the 2000s. Browser dropped support for such things; except a very simple pop-up api which is supported by UI5.

  • i assume you are in the shell.

Use the dirty flag properly(set it as long there are unsaved changes or a request still running) and the user will get a popup.

https://sapui5.hana.ondemand.com/sdk/#/api/sap.ushell.services.Container%23methods/setDirtyFlag

Related