On web, people try to avoid opening a new window. When opening a document from a view, users will expect to go back to the view that they come from. Users can access the same document from different views. Thus application have to be built to handle this.
One way to do this is passing the view name through the anchor link when opening the doc from the view. A simple way is to look through the view table DOM anchor and append the required query strings. I usually put the a div tag ("viewtable") around the embedded view in the $$ViewTemplate. This code below will look through the anchor link and append in the view name.
var anchor =
document.getElementById("viewtable").getElementsByTagName("a");
for(var i=0; i<=anchor.length; i++){
if(anchor[i] !== undefined){
anchor[i].href = anchor[i].href + "&view=" +
document.getElementById("viewname").value;}
}
This is a simple solution but when you have a large view, you have to take into consideration of the script performance. There should be a simpler way to do this. I just thought of using CGI values.
So I tried using HTTP_Referer. It returns the url of where you come from, thus it can be used to retrieve the view name. I store the view name in a hidden field for easy reference. The formula below can be used in the field to retrieve the view name from the HTTP_Referer. If it cannot find the view name in the HTTP_Referer, it will put in a default view name.
a:=@Left(@Right(HTTP_Referer; ".nsf/"); "?OpenView");
@If(a=""; "vMyAction"; a)
The "Close" button in the document can use the field to navigate back to the view.
When going from read to edit mode, the referer will be the read mode thus losing the view name info. A simple way around this is to pass the view name along in the URL when opening the document in edit mode or going back to read mode. It can easily be retrieve using @UrlQueryString.
There are many ways to do the document navigation from the view. You can use the methods above, cookies, etc. If you know a better or simpler way to do it, feel free to drop in your comments.
Show-n-Tell Thursday Add to del.icio.us
5 comments:
correct me if i'm wrong. AFAIK, calling @command fileclosewindow on the web will get u back to the view from which the document was opened. also, if u examine the document's url u see it is built like this:
http://host.domain/dbpath/dbname.nsf/viewid/docid?command
so the view can be extracted from the url :)
Samo -/-
Hi Samo, The link is not working.
Hello William,
That wasn't a link, it is just a url sample showing the components of a typical document url on domino.
Mayb if i put it like this it will be clearer:
[protocol]://[host].[domain]/[dbpath]/[dbname].nsf/[viewid]/[docid]?[command]
or
[protocol]://[host].[domain]/[dbid]/[viewid]/[docid]?[command]
The view ID part can be extracted with a simple javascript.. but i'm not keen in javascript to give an example right now.
-/-
I'm so blur.. Must be the lack of sleep..
Great Article
Online Javascript Course
Post a Comment