我设计了以下方法并在托管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中发生。
有什么想法吗?
答案 0 :(得分:6)
RedirectSignal 不是 java.lang.Exception ,它是 java.lang.Error 。这就是为什么它没有使用默认的try / catch块。还有一些其他信号f.e. NoAccessSignal 或 ResponseCompleteSignal ,它们在内部处理以停止处理请求和/或代码执行,但不是XPage servlet的“真正”错误。
当重定向到另一个页面时, RedirectSignal 需要停止处理“无用”代码并且在SSJS Interpreter中被捕获。带有此代码的按钮......
print("BEFORE!");
context.redirectToPrevious();
print("AFTER");
只会将 BEFORE!发送到控制台,其余的SSJS将不会被执行。
您必须自己处理 RedirectSignal (在bean的方法中)以防止打印到控制台/日志。
答案 1 :(得分:0)
XSPContext.getXSPContext(FacesContext)
只使用变量解析器来解析context
变量,因此此方法应返回context
计算到的同一对象的句柄SSJS。所以我不确定为什么你会看到不同语言的不同行为。
但是,仅在重定向期间检测到递归时才会显示RedirectSignal
。如果我正确解释您的堆栈跟踪,则refreshMode
会在您的活动中设置为partial
。必须在完整刷新事件中执行所有重定向。