Lien d'origine :
http://planetlotus.org/profiles/michael-gollmick_43466
Michael Gollmick
In the last days I have worked quite a bit with Domino XPages Technology. One thing that came up was the lack of an @WebDBName function that is missing in XPages. But the solution is more than easy and requires just a few lines of code. You may want to copy that because you just don't want to code it every time. For me this is a function I have put that function into some core Serverside JavaScript-Library I include into every page and Custom control anyway, so I can use it everywhere. I took the name I expected to have which is the only critical part - if that function is included at anytime in the future, that hand crafted function may cause problems or incompatibilities, so it might be a good idea to give it another name.
- Code : Tout sélectionner
/** *****************************************************************
* provides functionality of the function with same name from @Formula
*
* @return the name of the current database in a websave format
* @author Michael Gollmick
* @version 1.2
* @date 20090119
****************************************************************** */
function WebDBName() {
try {
if (typeof this.name === 'undefined') {
var path = database.getFilePath();
var re = new RegExp("\\\\", "g");
path = path.replace(re, "/");
var arr = path.split("/");
for (var a = 0; a < arr.length; a++) {
arr[a] = escape(arr[a]);
}
this.name = arr.join("/");
}
} catch (e) {
}
return this.name;
}
/* ******************************************************************
* END WebDBName
****************************************************************** */
Feel free to use it!
Pour ouvrir une xPage, un bouton avec js côté client :
- Code : Tout sélectionner
window.open("/" + "#{javascript:WebDBName()}" + '/MaPage.xsp')