on 2018 Nov 27 6:55 AM
Hi all,
I need a notification in FLP about every event, that my SAPUI5-App is going to be left by the user. My requirement is, that the user should be asked to save unsaved changes, before the leave event is executed.
So far I can identify three kinds of events:
Any suggestions for 2. and 3. are welcome.
Thank your very much und best regards,
Christian.
Hi Christian,
1- Solved as you said.
2- How register these events?
sap.ui.getCore().byId('homeBtn').attachPress(function() {
// Here your code
});
sap.ui.getCore().byId('backBtn').attachPress(function() {
// Here your code
});
How prevent the original coding execution?
Typing the next line in the functions above
sap.ui.getCore().getEventBus().destroy();
3- How capture browser events?
You can manage any URL change with the "Data Protection Loss" provided from SAPUI5. It's so easy as setting a flag variable and getting it after. Please refer to the next link: Data Loss Protection
I hope it helps you 🙂
Kind regards,
Jorge.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jorge,
thank you very much for your answer! I am sorry, that I could not answer earlier.
Attaching a listener to HomeBtn and BackBtn is what i was looking for. But when I call sap.ui.getCore().getEventBus().destroy(); in the first line of my callback function, the browser still executes one step back in history. When I set a breakpoint in my callback function I can see, that the chrome debugger stops for a short time and after that it loads the previous page and my js code stops executing.
Do you ever have a similar experience?
Best regards,
Christian.
Hi Jorge,
it was a misconfiguration of my test setting. I loaded the App on my FLP in debug-mode. So there was no history entry for the flp and in this case the flp does a browser history back and the browser loads the previous page from scratch.
When I first load the FLP Startpage in debug mode and navigate to my app, then the back button calls my function and I can destroy the event.
Do you know, how do I best listen to URL changes? Do I use HashChanger and attach to the "hashChanged" event?
Best regards,
Christian.
Hi Jorge,
I should have started with Data Loss Protection (-; As you said, that's everything I wanted! But it is badly documented and I did not understand it right away.
Thank you very much!
Best regards,
Christian.
User | Count |
---|---|
67 | |
10 | |
10 | |
10 | |
7 | |
7 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.