Question

I have written my own JSF handler deriving it from the ExceptionHandlerWrapper. Inside the handle method I have the following code:

NavigationHandler navigationHandler = fc.getApplication().getNavigationHandler();
navigationHandler.handleNavigation(fc, null, "error");
fc.renderResponse();

The problem is that on a page which has a primefaces poll element:

<p:poll ajax="true" interval="10" widgetVar="pollPing" autoStart="false" oncomplete="remoteCommandPing()"/>

browser gets redirected only after the "interval" seconds of time. This means that I have to wait up to 10 seconds in my case to get redirected. Inside the error handler I need to somehow stop any current requests to the server (in my case done by the poll) and redirect immediately. I tried to use the following code prior to navigation:

FacesContext fc = FacesContext.getCurrentInstance();
ExternalContext extCtx = fc.getExternalContext();
extCtx.responseReset();

but all I get is:

XML Parsing Error: no element found

meaning that the server response was empty (apparently because of extCtx.responseReset();), after which no redirection to the error page occurs.

Does anyone know how to simply stop all requests and force redirection to some faces managed page? I tried various solutions involving setViewRoot and some code snippets from OminFaces' FullAjaxExceptionHandler.java without any luck. Thanks.

Was it helpful?

Solution

you may surround your java code by a try catch and in the catch block do:

FacesContext.getCurrentInstance().getExternalContext().redirect("foo.xhtml");

Id this doesn't answe your question you may want to give more code, and try to explain better your problem

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top