1

我设计了以下方法并在托管 bean 中使用它:

public static void redirectToPrevious() {
    FacesContext context = FacesContext.getCurrentInstance();
    XSPContext xContext=XSPContext.getXSPContext(context);
    xContext.redirectToPrevious();
}

它按预期工作。它重定向到上一页(或主页,如果没有的话)。

但是,每次它工作时,它都会抛出 RedirectSignal 错误:

com.ibm.xsp.FacesExceptionEx: javax.faces.el.EvaluationException: com.ibm.xsp.acl.RedirectSignal
at com.ibm.xsp.util.DataPublisher.publishControlData(DataPublisher.java:204)
at com.ibm.xsp.component.UIDataPanelBase.publishControlData(UIDataPanelBase.java:310)
at com.ibm.xsp.component.UIDataPanelBase.initBeforeContents(UIDataPanelBase.java:451)
at com.ibm.xsp.component.UIIncludeComposite.initBeforePageContents(UIIncludeComposite.java:668)
at com.ibm.xsp.page.compiled.AbstractCompiledPage.initComponent(AbstractCompiledPage.java:339)
at com.ibm.xsp.page.compiled.AbstractCompiledPage.createTree(AbstractCompiledPage.java:256)
at com.ibm.xsp.page.compiled.AbstractCompiledPage.addComponent(AbstractCompiledPage.java:389)
at com.ibm.xsp.component.UIIncludeComposite.buildContents(UIIncludeComposite.java:453)
at com.ibm.xsp.page.compiled.AbstractCompiledPage.initComponent(AbstractCompiledPage.java:334)
at com.ibm.xsp.page.compiled.CompiledComponentBuilder.buildFacet(CompiledComponentBuilder.java:205)
at com.ibm.xsp.component.UICallback.buildContents(UICallback.java:180)
at com.ibm.xsp.page.compiled.AbstractCompiledPage.initComponent(AbstractCompiledPage.java:334)
at com.ibm.xsp.page.compiled.CompiledComponentBuilder.buildChildren(CompiledComponentBuilder.java:123)
at com.ibm.xsp.page.compiled.CompiledComponentBuilder.buildAll(CompiledComponentBuilder.java:84)
at com.ibm.xsp.extlib.component.layout.UIVarPublisherBase.buildContents(UIVarPublisherBase.java:97)
at com.ibm.xsp.page.compiled.AbstractCompiledPage.initComponent(AbstractCompiledPage.java:334)
at com.ibm.xsp.page.compiled.CompiledComponentBuilder.buildChildren(CompiledComponentBuilder.java:123)
at com.ibm.xsp.page.compiled.CompiledComponentBuilder.buildAll(CompiledComponentBuilder.java:84)
at com.ibm.xsp.component.UIIncludeComposite.buildPageContents(UIIncludeComposite.java:692)
at com.ibm.xsp.page.compiled.AbstractCompiledPage.initComponent(AbstractCompiledPage.java:340)
at com.ibm.xsp.page.compiled.AbstractCompiledPage.createTree(AbstractCompiledPage.java:256)
at com.ibm.xsp.page.compiled.AbstractCompiledPage.addComponent(AbstractCompiledPage.java:389)
at com.ibm.xsp.component.UIIncludeComposite.buildContents(UIIncludeComposite.java:453)
at com.ibm.xsp.page.compiled.AbstractCompiledPage.initComponent(AbstractCompiledPage.java:334)
at com.ibm.xsp.page.compiled.CompiledComponentBuilder.buildChildren(CompiledComponentBuilder.java:123)
at com.ibm.xsp.page.compiled.CompiledComponentBuilder.buildAll(CompiledComponentBuilder.java:84)
at com.ibm.xsp.component.UIViewRootEx.buildContents(UIViewRootEx.java:1649)
at com.ibm.xsp.component.UIViewRootEx2.buildContents(UIViewRootEx2.java:247)
at com.ibm.xsp.page.compiled.AbstractCompiledPage.initComponent(AbstractCompiledPage.java:334)
at com.ibm.xsp.page.compiled.AbstractCompiledPage.createTree(AbstractCompiledPage.java:256)
at com.ibm.xsp.page.compiled.AbstractCompiledPage.createViewRoot(AbstractCompiledPage.java:167)
at com.ibm.xsp.application.ViewHandlerExImpl._createViewRoot(ViewHandlerExImpl.java:521)
at com.ibm.xsp.application.ViewHandlerExImpl.createViewRoot(ViewHandlerExImpl.java:567)
at com.ibm.xsp.application.ViewHandlerExImpl.doCreateView(ViewHandlerExImpl.java:142)
at com.ibm.xsp.application.ViewHandlerEx.createView(ViewHandlerEx.java:90)
at com.ibm.xsp.webapp.FacesServlet.serviceView(FacesServlet.java:251)
at com.ibm.xsp.webapp.FacesServletEx.serviceView(FacesServletEx.java:157)
at com.ibm.xsp.webapp.FacesServlet.service(FacesServlet.java:160)
at com.ibm.xsp.webapp.FacesServletEx.service(FacesServletEx.java:138)
at com.ibm.xsp.webapp.DesignerFacesServlet.service(DesignerFacesServlet.java:103)
at com.ibm.designer.runtime.domino.adapter.ComponentModule.invokeServlet(ComponentModule.java:576)
at com.ibm.domino.xsp.module.nsf.NSFComponentModule.invokeServlet(NSFComponentModule.java:1315)
at com.ibm.designer.runtime.domino.adapter.ComponentModule$AdapterInvoker.invokeServlet(ComponentModule.java:853)
at com.ibm.designer.runtime.domino.adapter.ComponentModule$ServletInvoker.doService(ComponentModule.java:796)
at com.ibm.designer.runtime.domino.adapter.ComponentModule.doService(ComponentModule.java:565)
at com.ibm.domino.xsp.module.nsf.NSFComponentModule.doService(NSFComponentModule.java:1299)
at com.ibm.domino.xsp.module.nsf.NSFService.doServiceInternal(NSFService.java:662)
at com.ibm.domino.xsp.module.nsf.NSFService.doService(NSFService.java:482)
at com.ibm.designer.runtime.domino.adapter.LCDEnvironment.doService(LCDEnvironment.java:350)
at com.ibm.designer.runtime.domino.adapter.LCDEnvironment.service(LCDEnvironment.java:306)
at com.ibm.domino.xsp.bridge.http.engine.XspCmdManager.service(XspCmdManager.java:272)

Caused by: javax.faces.el.EvaluationException: com.ibm.xsp.acl.RedirectSignal
    at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:142)
    at com.ibm.xsp.actions.ExecuteScriptAction.invoke(ExecuteScriptAction.java:78)
    at com.ibm.xsp.actions.ActionGroup.invoke(ActionGroup.java:135)
    at com.ibm.xsp.model.AbstractDocumentDataSource.invoke(AbstractDocumentDataSource.java:299)
    at com.ibm.xsp.model.AbstractDocumentDataSource.newDocument(AbstractDocumentDataSource.java:126)
    at com.ibm.xsp.model.AbstractDocumentDataSource.load(AbstractDocumentDataSource.java:97)
    at com.ibm.xsp.model.AbstractDataSource.getDataContainer(AbstractDataSource.java:474)
    at com.ibm.xsp.model.domino.DominoDocumentData.getDataObject(DominoDocumentData.java:145)
    at com.ibm.xsp.model.AbstractDataSource.pushData(AbstractDataSource.java:576)
    at com.ibm.xsp.util.DataPublisher.publishControlData(DataPublisher.java:181)
    ... 50 more
Caused by: com.ibm.xsp.acl.RedirectSignal
    at com.ibm.xsp.designer.context.XSPContext.renderPage(XSPContext.java:194)
    at com.ibm.xsp.designer.context.XSPContext.redirectToPage(XSPContext.java:917)
    at com.ibm.xsp.designer.context.XSPContext.redirectToPage(XSPContext.java:929)
    at com.ibm.xsp.designer.context.XSPContext.redirectToPrevious(XSPContext.java:939)
    at com.developi.toolbox.BeanUtils.redirectToPrevious(BeanUtils.java:57)
    at com.hillside.flowng.beans.JobManager.postNewJob(JobManager.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:611)
    at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:138)
    ... 59 more

我可以使用 try-catch 并忽略该错误,但我不确定为什么这会发生在托管 bean 中而不是 SSJS 中。

任何想法?

4

2 回答 2

6

RedirectSignal不是java.lang.Exception,而是java.lang.Error。这就是为什么它没有被默认的 try/catch 块捕获。还有一些其他信号来自NoAccessSignalResponseCompleteSignal,它们在内部处理以停止处理请求和/或代码执行,但对于 XPages servlet 来说不是“真正的”错误。

重定向到另一个页面时,需要RedirectSignal停止处理“无用”代码,并在 SSJS 解释器中捕获。带有此代码的按钮...

print("BEFORE!");
context.redirectToPrevious();
print("AFTER");

只会发送之前!到控制台,其余的 SSJS 将不会被执行。

您必须自己处理RedirectSignal(在您的 bean 的方法中)以防止打印到控制台/日志。

于 2013-04-10T12:40:20.683 回答
0

XSPContext.getXSPContext(FacesContext) just uses the variable resolver to resolve the context variable, so this method should return a handle on the same object that context evaluates to within SSJS. So I'm not sure why you would see different behavior in different languages.

However, a RedirectSignal is only shown when recursion has been detected during a redirect. If I'm interpreting your stack trace correctly, refreshMode is set to partial on your event. All redirects must be performed from within a full refresh event.

于 2013-04-10T11:03:04.603 回答