I have a repeat-control which generates me a list of links to documents in a different database. Special on this task is that the XPage runs in the notes internal browther (NOT XPniC) and open the documents as real notes documents in the notes client (NOT Xpages). so far every thing works fine. Now I want too check if the document exists before I open the document.
My solution is an xAgent which check if the document exists and redirect to the NotesURL but I get the following error:
Error source
Page Name:/xaOpenDocument.xsp
Exception
Error while executing JavaScript action expression
Script interpreter error, line=25, col=43: Error calling method 'redirect(java.lang.String)' on java class 'com.ibm.xsp.domino.context.DominoExternalContext'
notes://SERVER01@SRV@DE@OU@MyCompany AG/__C1257B6B002A0472.nsf/0/C1257B6B002A0472C12574CD0024E6B9
The link to the xAgent looks like this:
http://SERVER02/dev/release_4/test_xui.nsf/xaOpenDocument.xsp?dbServer=SERVER01%2FSRV%2FDE%2FOU%2FMyCompany+AG&dbPath=dev%5C%5Crelease_4%5C%5Ctest_adr&docUNID=C1257B6B002A0472C12574CD0024E6B9
The xAgent code looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" rendered="false">
<xp:this.afterPageLoad><![CDATA[#{javascript:var server:string = context.getUrlParameter("dbServer");
var db:string = context.getUrlParameter("dbPath");
var unid:string = context.getUrlParameter("docUNID");
var url:string = "";
var targetDB:NotesDatabase = session.getDatabase(server,db);
var doc:NotesDocument = targetDB.getDocumentByUNID(unid);
if(doc == null){
requestScope.put("targetDocUNID",unid);
println("xaOpendocument targetDocUNID: " + unid);
requestScope.put("dbServer",server);
println("xaOpendocument dbServer: " + server);
requestScope.put("dbPath",db);
println("xaOpendocument dbPath: " + db);
requestScope.put("targetError","Dokument konnte nicht geöffnet werde. \n Document wurde verschoben oder entfernt.");
println("xaOpendocument URL: xpErrorMessage.xsp");
context.redirectToPage("xpErrorMessage.xsp");
}else{
url = sessionUser.getDocumentURL(targetDB,unid);
println("xaOpendocument: Dokument wurde gefunden... Umleiten!");
println("xaOpendocument URL: " + url);
facesContext.getExternalContext().redirect(url);
}}]]></xp:this.afterPageLoad>
</xp:view>
The Serverconsole shows me the following error lines:
30.07.2013 11:17:47 HTTP JVM: xaOpendocument: Dokument wurde gefunden... Umleiten!
30.07.2013 11:17:47 HTTP JVM: xaOpendocument URL: notes://SERVER02@SRV@DE@OU@MyCompany AG/__C1257B6B002A0472.nsf/0/C1257B6B002A0472C12574CD0024E6B9
30.07.2013 11:17:47 HTTP JVM: com.ibm.xsp.webapp.FacesServlet$ExtendedServletException: com.ibm.xsp.exception.EvaluationExceptionEx: Error while executing JavaScript action expression
30.07.2013 11:17:47 HTTP JVM: CLFAD0134E: Exception processing XPage request. For more detailed information, please consult error-log-0.xml located in F:/Lotus/data/domino/workspace/logs
I hope for some useful help - I wasted already to much time on this problem. I thought it should be simple. :/