4

I need to do some clean-up when a user exits a xe:dialog. I put the code in the onUnload event like this:

viewScope.remove("vsSomeVariable");
viewScope.remove("vsAnotherVariable");
etc;

but when the userr clicks the "X" on the dialog this code does not execute. I have added some print to the console statements in my code and the onUnload does not fire when I think it should. it would appear that the sequence is onLoad, then onUnload, then the user does their thing and if they click the "X" the onUnload does not appear to execute. Is there a way to disable the "X" in the xe:dialog so I can create an "Exit" button that will do what I want, or trap the click on the "X" so that I can do my clean up process?

Knut Herrmann
  • 30,880
  • 4
  • 31
  • 67
Bill F
  • 2,057
  • 3
  • 18
  • 39

1 Answers1

4

Add your SSJS code to xe:dialog's onHide or onUnload event:

<xe:dialog id="dialog1">
   <xe:this.onHide><![CDATA[#{javascript:print("onHide")}]]></xe:this.onHide>
   <xe:this.onUnload><![CDATA[#{javascript:print("onUnload")}]]></xe:this.onUnload>

But, make sure you put your code into All Properties

enter image description here

and not into Events

enter image description here

Knut Herrmann
  • 30,880
  • 4
  • 31
  • 67
  • It works the way I want it to by adding it to the onHide. The onUnload seems to fire right after the onLoad so it does not appear to fire when the "X" is pressed. But the onHide works like a charm, and I had tried the events and could not get anything to work. Went to the Properties and started to get somewher. Thanks for the pointer. – Bill F Sep 18 '14 at 21:34