Thursday, January 18, 2007

Domino forms and the Back button of the browser

Suppose you have a sequence of application steps as following:
UNID?EditDocument -> user change -> document is saved and redirect user to UNID?OpenDocument

More than that, suppose it's an application already working, which performs a JS sumbit(), then the WQS agent kicks in, create the document, then the same agent does :
Print "[/" & web_db_name & "/(someView)/" & docSaved.UniversalID & "?OpenDocument]"
which is basically the redirection.

Where does the Back button fit this picture ? from OpenDocument resulting page, if the user performs Right Click/Back, it ends up in the same EditDocument page and you don't want that. What to do ?

The simplest solution to avoid this:
Instead of printing the redirection URL directly, print the HTML code of a page which performs the redirection on the onload event. The code would look like this:

Sub Initialize

... set doc context, perform some rocket science

Dim sLocation As String

sLocation= "/" + UtilEscapePath (db.FilePath) + "/(someView)/" & docSaved.UniversalID & "!OpenDocument"

WebReturnUrl (sLocation)

End Sub

The UtilEscapePath and WebReturnUrl are two subroutines which you can find in the names.nsf of your server (WebLSUtil library, for Domino 6). Thanks IBM for that, good idea ! It is sometimes useful to have a look into the design of Domino default templates, specific the system names.nsf :)
UtilEscapePath basically changes \ with / so it will comply with URL format. Most interesting is WebReturnUrl:

Sub WebReturnUrl(sLocation As String)

Print _



<body onLoad="window.location = '| + sLocation & |'"></body>



End Sub

There you have it, the first 'level' of Back will no longer open the document in Edit mode. This is not a full-proof solution as selecting browser's drop-down and going back two 'levels' will of course break this. However for the 'right-click/back' it works and may be sufficient for your application.
Post a Comment

Disclaimer: The information in this weblog is provided "AS IS" with no warranties whatsoever, and confers no rights to any institution/person/organization. These are my personal thoughts and ideas. When I am inspired by others I give credit, I do not assume other's work and efforts. This site is NOT supported, approved, blessed etc. by Lotus Software and/or IBM Corporation.

Creative Commons License

This work is licensed under a Creative Commons Attribution 3.0 License.