2

I want to have a pop-up dialog box to remind the user to save the changes made before closing the window. If the user has already clicked on save button, then the window can be closed. But if the user forgot to click on save and is trying to close the window, only then the popup has to appear to remind him to save the changes

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
Nikhil G
  • 31
  • 2
  • I am using JSF primefaces for the project – Nikhil G Jul 14 '18 at 09:49
  • 1
    What did ypu try? What did ypu search/investigate many similar q/a in stackoverflow if I remember correctly – Kukeltje Jul 14 '18 at 10:55
  • Hi Kukeltje, I was able to show a dialog box when the changes are not saved. However, if a condition satisfies and the user clicks on save button, i want the window to close from the backing bean. I am using window.close() but it is not working as expected if(condition()==false) { context.execute("PF('dialogbox').show();"); } – Nikhil G Jul 17 '18 at 11:10
  • Sorry, but I fail to understand your comment... – Kukeltje Jul 17 '18 at 11:28

1 Answers1

1

I hope it will help

Click [To get browser close event in java script] (Trying to detect browser close event)

Click [To do it with managed beans] (Is there a way to call a method upon leaving a page with JSF or PrimeFaces?)