0

I got a small xpage containing a button with the following on click event:

context.redirectToPage("http://server:8080/AWM.nsf/viewAllDocuments.xsp", false);

As soon as I click on the button I geht the following error message:

Error while executing JavaScript action expression Script interpreter error, line=1, col=9: [TypeError] Exception occurred calling method XSPContext.redirectToPage(string, boolean)
com.ibm.xsp.page.PageNotFoundException: Could not create the page /http://server:8080/AWM.nsf/viewAllDocuments.xsp because the class xsp.http_003a._002fserver_003a8080.awm.nsf.ViewAllDocuments could not
be found. Please check your spelling.
com.ibm.xsp.page.PageNotFoundException: Could not create the page /http://server:8080/AWM.nsf/viewAllDocuments.xsp because the class    xsp.http_003a._002fserver_003a8080.awm.nsf.ViewAllDocuments could not
be found. Please check your spelling. Could not create the page /http://server.de:8080/AWM.nsf/viewAllDocuments.xsp because the class
xsp.http_003a._002fserver_003a8080.awm.nsf.ViewAllDocuments could not be found. Please check your spelling. Cannot find class    xsp.http_003a._002fserver_003a8080.awm.nsf.ViewAllDocuments in NSF

I tried to rebuild the database and did a clean, but nothing changes. The xpage viewAllDocuments.xsp exists and if I copy the path of the error message and try to open the page directly, that works.

Can anybody give me a hint here?

4

2 回答 2

2

像您所做的那样,将第二个参数设置为 false,显然会尝试将您的新 URL 解释为相对于您当前 URL 的资源(因此错误提到“ /http ://...”)。

将第二个参数设置为 true 新 url 将附加到您当前的 URL:如果您当前在

http://myserver/mydb.nsf/mypage.xsp

然后url被解析为

http://myserver/mydb.nsf/http://newserver/newpath.html.xsp

至少这就是我的测试服务器(8.5.3)上的测试数据库中发生的事情。不知道有没有办法防止这种情况;我通常使用链接控件(如果它必须看起来像一个按钮,没问题:插入一个看起来像一个按钮的图像),或者我使用客户端脚本,如

location.href="http://newserver/newresource"
于 2013-04-29T11:34:58.053 回答
2

redirectToPage尝试通过删除第二个参数false或将其设置为来更改您的代码true。这应该有效:

context.redirectToPage("http://server:8080/AWM.nsf/viewAllDocuments.xsp")

或者你可以这样写:

facesContext.getExternalContext().redirect("http://server:8080/AWM.nsf/viewAllDocuments.xsp")

当您将第二个参数设置false为重定向发生在服务器上时,因此您必须编写类似这样的内容才能使其工作(假设viewAllDocuments.xsp在同一个数据库中):

context.redirectToPage("viewAllDocuments.xsp", false)

当重定向发生在服务器上时,浏览器上的 URL 不会更新,但页面会更新。

有关详细信息,请参阅Mark Leusink 的文档redirectToPage本文

于 2013-04-29T11:16:06.030 回答