Reputation: 190
As a follow up to my question @PreDestroy method not called when leaving page of bean annotated with OmniFaces "ViewScoped" I have one other question:
Is it possible to process the JavaScript unload
event manually before the @PreDestroy
annotated method in an OmniFaces ViewScoped
bean and only trigger the later conditionally if the user confirmed the question? I want to keep using the unload
event to confirm whether the user really wants to leave the current page like this
window.onbeforeunload = (on) ? function() { return true; } : void 0;
and only bubble the event to the bean annotated with the OmniFaces @ViewScoped
annotation and trigger the @PreDestroy
annotated method if the user confirmed the initial Do you really want to leave the page?
question by clicking Yes
.
Is that possible?
Upvotes: 1
Views: 94