如果用户输入带有action=editDocument的网址,我希望能够将他们重定向到相同的网址,但使用的是action=openDocument。
我假设我将使用beforePageLoad事件?
我如何才能阻止他们访问action=editDocument并将他们重定向到action=openDocument url?
发布于 2012-06-29 04:51:08
如果参数action为"editDocument“,下面的代码将重定向回同一页面(从而阻止用户编辑文档):
<xp:this.beforePageLoad>
<![CDATA[#{javascript:
if (param.get("action")=="editDocument") {
context.redirectToPage(view.getPageName())
}
}]]>
</xp:this.beforePageLoad>更新:正如马克在他的答案中指出的那样,如果包含上述答案,则不会保留documentId参数。您可以检查是否包含documentId参数,然后使用该参数执行正确的重定向:
<xp:this.beforePageLoad>
<![CDATA[#{javascript:
if (param.get("action")=="editDocument") {
context.redirectToPage(view.getPageName() + "?action=openDocument&documentId=" + param.get("documentId")
}
}]]>
</xp:this.beforePageLoad>发布于 2012-07-02 18:00:00
如果您有editDocument,那么请求中可能会有一个docID,在这种情况下,view.getRequestUrl()比view.getpageName()更有用
https://stackoverflow.com/questions/11251232
复制相似问题