My goals were to:
- Simplify the unsightly URL's
- Prevent the URL's from revealing the presence of a second database
- Prevent the user from using bookmarks or the address bar and jumping into the middle step of a multistep process
I was able to accomplish the first two of these goals and this post will explain who I accomplished them. The third goal is still outstanding. I will make a follow up post when/if I figure that one out.
Before:
This was the URL to open a document prior to making the changes outlined here:
http://notesdev1.my_company.com/po/po.nsf/%24%24OpenDominoDocument.xsp?databaseName=CN=My_Company_NotesDev1/O=MyDomain!!PO%5CPO-data.nsf&documentId=E879C68A9A88F6DD87257BC6005A0748&action=editDocument
This URL is very unsightly, and shows that I keep my data in a separate NSF. It is also extremely long.
After:
This URL does the same as the first and opens the same document in the same database
http://notesdev1.my_company.com/po/po.nsf/New_PO.xsp?doc=E879C68A9A88F6DD87257BC6005A0748
Notice that the URL does not reveal the location of the data, or my companies Notes domain.
The Remedy:
Before I explain here what I did, let me say that I would not have been able to come up with this without the help of Stephan Wissell and Per Henrik Lausten via Stack Overflow. Here is the link to my question.
The fix is two part.
First, you have to manually build your URL in the container where you display your documents. In my case, I am using a view control, which is really a placeholder until I decide how I want to display the data. These instructions might have to modified for other containers.
A) Give the View control a value in the 'var', I used 'viewData'
B) In the onClick event of the column that is set to display as link, add the following code
var xpage = "New_PO.xsp"
var unid = viewData.getDocument().getUniversalID()
facesContext.getExternalContext().redirect(xpage + "?doc=" + unid);
The result of this is the after URL listed above.
The second part is to read the shortened URL:
In the Xpage Properties under Data, do the following:
A) Create your data source as you normally would
B) Specify the location of your data whether it is in the current NSF or another. I prefer to separate data and design.
C) Change the 'Default action' to Open Document, or Edit Document
D) In the 'Document id' calculate the value to return param.get("doc") which grabs the UNID that you passed
The result is that you have a nice looking URL and you can bind to any database without revealing it through the URL parameters. I have read that you can accomplish similar results using site documents, but I wanted a solution that works whether your administrator is friendly or not.
No comments:
Post a Comment