2
votes

Inside XPages I'm using some controller classes to bind the XPages's beforePageLoad() event to a Java Method.

In this method I want to redirect the user to a different web page. It works.. BUT it throws a ton of errors on the console.

public void beforePageLoad() throws Exception {

        Map<String, String> param = (Map<String, String>) XSPUtil.resolveVariable("param");
        if (!param.containsKey("exhibitorId")) {
            System.out.println("Redirecting");
            FacesContext fc = FacesContext.getCurrentInstance();
            ExternalContext externalContext = fc.getExternalContext();

            XSPContext context = XSPContext.getXSPContext(fc);
            context.redirectToPage("/test.xsp");
}

That's the basic code.. I've tried with the externalContext... this sample is showing the XSPContext. So I'm just not sure how to do it.

The binding to an event isn't a problem. That's working great. It's just using the event in Java to redirect to another page. Some of the messages I'm getting are:

2/9/15 1:06 PM: Exception Thrown Context Path: /coms/exhibitor.nsf Page Name: /home.xsp javax.faces.el.EvaluationException: com.ibm.xsp.acl.RedirectSignal at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:142) at com.ibm.xsp.component.UIViewRootEx.initBeforeContents(UIViewRootEx.java:1621) at com.ibm.xsp.page.compiled.AbstractCompiledPage.initComponent(AbstractCompiledPage.java:333) 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 frostillicus.controller.ControllingViewHandler.createView(ControllingViewHandler.java:89) 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:1335) 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:1319) 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 org.openntf.domino.xsp.adapter.OpenntfHttpService.doService(OpenntfHttpService.java:86) at com.ibm.designer.runtime.domino.adapter.LCDEnvironment.doService(LCDEnvironment.java:357) at com.ibm.designer.runtime.domino.adapter.LCDEnvironment.service(LCDEnvironment.java:313) at com.ibm.domino.xsp.bridge.http.engine.XspCmdManager.service(XspCmdManager.java:272) 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 controller.home.beforePageLoad(home.java:44) 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)

1

1 Answers

7
votes

This is not an error. Just an exception to notify other processes. Normally, SSJS processor uses this to stop further processing of the code.

You might ignore that:

try {
    context.redirectToPage("/test.xsp");
} catch (RedirectSignal rs) {
    // Ignoring this error. Useless!
}