I may be giving this a man look but I cannot find a way to Close a document in XPages. I can Open, Edit and Change Mode but there is no option to Close a document and return to wherever you came from. I have to be missing seeing something right under my nose, so at the risk of appearing foolish can anyone advise me please? Working in 8.5.1. Beta.
Subject: Open page
You need to look at the ‘Open Page’ event.
You can then set this to ‘Open Previous’ which will close the existing page and open the one you went to last. Chuck in a ‘Save’ event to keep the document as well.
Check out Decs Dom blog. One of the initial tutorials will explain the save, edit, close buttons.
Subject: sessionScope
Thanks Ian. I could not find an option to ‘Open Previous’ as a subsequent option to ‘Open Page’. Nice idea though. I ended up using sessionScope on each of the XPages that contains a view by using afterPageLoad with the following:
sessionScope.put(“returnTo”,“name_of_xpage.xsp”);
In the onClick event for the Close link on a document I set it to use the sessionScope variable like this:
context.redirectToPage(sessionScope.returnTo, false);
Primitive but it works. The down side is that it does not return to the part of the view that you left, as the browser back button does, but opens the page with a fresh view. I tried using history.go(-1) as a test but it failed sadly.
The ‘put’ method is supposed to only work for existing sessionScope variables so my home page instantiates the variable for subsequent use, however testing by going directly to a page which uses ‘put’ without going via the home page also works.