XPage @WebDbName Option

Mindwatering Incorporated

Author: Tripp W Black

Created: 12/23/2011 at 06:25 PM

 

Category:
Notes Developer Tips
XPages

Issue:
@WebDbName() not available in Xpages.

Simple Formula Solution:
This solution does both the slash and converts the space to a plus.

var tmppathfix1 = @Implode(@Explode(@Subset(@DbName(),-1), @Char(92)),'/');
var tmppathfix2 = @Implode(@Explode(tmppathfix1, ' '),'+');
'/' + tmppathfix2;

Another SSJS example would be:
var url1 = facesContext.getExternalContext().getRequest().getContextPath();
or
var url1 = facesContext.getExternalContext().getRequestContextPath();

For http://www.mindwatering.com/MW.nsf, the above would return /MW.nsf.


Example of URL redirection using a button in a view:
Add a button to a XPage. In the Simple Action (SSJS).

Enter the following code:

var extCont = facesContext.getExternalContext();
var url1 = facesContext.getExternalContext().getRequest().getContextPath();
var url2 = url1 + '/mypage.xsp?action=newDocument&unidkey=' + vRowData.getUniversalID();
extCont.redirect(url2);

Note: The above code uses the button view column hack on page 223-224 of the Mastering Xpages book.


previous page