Open Parent Instead of Response
For a recent project, I was updating an application to use XPages. The application has parent documents and many response documents. One of the response documents is a "summary" document that gathers up information from all the other responses. The users would have preferred to show that information in the parent document, but the response document was slow to open. Turns out that it was slow to open because of some design considerations. Anyway, in the XPages version, I put all that summary information into the main XPage. So the response document isn't really needed any more. But I'm not recreating the application, only adding the XPages part for use on the web. This means that there will still be that summary response document. (Also, existing documents would have the summary document).
I decided to make an XPage for the summary document that would open up the main XPage. I could have recreated all the content (using custom controls) with a data source of the parent instead of the response, but then I'd have to deal with editing and some other stuff. I decided it would just be better to never officially open the response - when you click on the response in a view, the parent will be opened instead.
On the XPage that's tied to the response document, I added onClientLoad code to open the parent XPage:
var responseUNID:string = context.getUrlParameter("documentId");
var db:NotesDatabase = session.getCurrentDatabase();
var responseDoc:NotesDocument = db.getDocumentByUNID(responseUNID);
var parentUNID:string = responseDoc.getParentDocumentUNID();
var url:string = "/" + webDbName() + "/main.xsp?documentId=";
url += parentUNID + @Char(38) + "action=openDocument";
responseDoc.recycle();
db.recycle();
facesContext.getExternalContext().redirect(url);
Note the use of webDbName() in the code. That's a generic function that mimics @WebDbName from formula language:
function webDbName() {
var p:string = @DbName()[1];
p = @ReplaceSubstring(p, "\\", "/");
return p;
}