XSP.attachEvent() and page unload

  • I have a link that does a Cancel. This link has an actionGroup that runs server-side script, and loads a page. It works fine as frog hair - the server-side script runs and the data on the XPage are not saved, exactly as needed.- I would like to be able to run these exact same actions for a page unload. I see in the page source that the Cancel link/button is doing this:

XSP.attachEvent(“”, “”, “onclick”, null, true, true);

  • It seems a possibility would be to add my own attachEvent to “onunload”. Then if the link actions are changed, the onunload actions will change as well. In this instance that’s desirable.

  • But I can’t figure out how to acquire , which is something relating to Domino’s automagic. If I search page source for that ID, it only appears here, on this attachEvent(). That seems more than a little strange, given the code I see in the xspClientDojo.js.uncompressed.js file. It appears this parameter is required for proper _processListeners() operation, which is ultimately what “does the work”.

  • Perhaps I’m barking up the wrong tree? I did look for some sort of unload event, but nothing exists, so I’m thinking attachEvent() or dojo.connect(), are the likely solutions. I looked up the docs for dojo.connect, and attachEvent() uses that internally, but it still appears I’ll need this “magic” element ID to bind using that, too.

  • I’d appreciate any suggestions. For instance, since this is a page unload, maybe I should simply pass a null here and let it bind globally?

Thanks for your time…

EDIT:

  • Passing null for the first parm doesn’t work. It doesn’t crash, which is a Good Thing! ™. It goes blank for a second, then reloads the page in edit mode, tossing all changes, except computed values in other custom controls says “Notes Exception: Object has been recycled”. Uh oh.