How would I run a legacy Agent on a XPage before it renders?

  • In days of yore I ran code in postOpenDocument on the Form and all was well. I have postOpenDocument in XPages, but I can’t simply call legacy code from there like I could on a Form. I have to encapsulate it in a Agent in order to launch it. I have recently discovered I can’t save the document that’s defined as the data source, in postOpenDocument, or postSaveDocument will never fire, and data will never actually be saved. So the parameter document method I use in postSaveDocument is right out.

  • Another sort of sticking point is that postOpenDocument is a server-side event now, not a client-side event. If it were client-side I’d do an AJAX call and be done. Can server-side even do that? If it can, is the code the same as client side? (dojo.xhrPost(), etc) Or do I have to fall back to the old way?

  • If it can’t do that is there some alternative place I can put a legacy Agent call that will it to run before the page is loaded? Far as I know every single event on a XPage is server-side, so even beforePageLoad won’t work any different than postOpenDocument, it just happens at a different time. I’m not aware of any way to touch off an Agent from the client until after the page is rendered, and then it’s too late.

Thanks for your time…

EDIT:

The Domino wiki says not one thing about this that I can find. Searching for postOpenDocument gives zero hits. Searching for “XPage AND WebQueryOpen” gives three hits, none of which are relevant. “server-side AND AJAX” yields four hits, none of which are relevant.

Subject: AJAX doesn’t work…

  • I spent the last four hours getting an ajax request set up (had to do it manual - dojo is client-side only) and attempting to call the Agent from postOpenDocument. I dump the URL it computed to the server console so I can verify it’s correct. Even though it calls the Agent when I put that URL in the address box, and there are no errors that I can find:
  1. postOpenDocument gets a null back instead of the JSON the Agent creates.

  2. The Agent never runs because there is no log.

This Agent runs fine using client-side AJAX calls so I know it works. It simply appears one can’t invoke an Agent from postOpenDocument via AJAX.

  • Any other ideas?..