myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthias Fischer <Matthias.Fisc...@doubleSlash.de>
Subject Problem with redirect in custom navigation handler
Date Wed, 12 Jul 2006 21:12:56 GMT
In a custom navigation handler I want to redirect directly if outcome
string looks as follows:
redirect:/path/to/my/view.jsp

Here is the part of the code which is responible for that:

      if (outcome.startsWith(PREFIX_REDIRECT)) {

         ExternalContext externalContext =
facesContext.getExternalContext();
         ViewHandler viewHandler =
facesContext.getApplication().getViewHandler();
         String redirectPath = viewHandler.getActionURL(facesContext,
outcome.substring(PREFIX_REDIRECT.length()));

         try {
           
externalContext.redirect(externalContext.encodeActionURL(redirectPath));
         } catch (IOException e) {
            throw new FacesException(e.getMessage(), e);
         }
         facesContext.responseComplete();
      }

Anyone an idea why I get the following exception?
Maybe there is a better way to redirect in an action method... if so please tell me.


java.lang.IllegalStateException
	at org.apache.catalina.connector.ResponseFacade.sendRedirect(ResponseFacade.java:432)
	at javax.servlet.http.HttpServletResponseWrapper.sendRedirect(HttpServletResponseWrapper.java:125)
	at org.apache.myfaces.context.servlet.ServletExternalContextImpl.redirect(ServletExternalContextImpl.java:489)
	at de.doubleslash.myfaces.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:126)
	at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:84)
	at javax.faces.component.UICommand.broadcast(UICommand.java:106)
	at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:90)
	at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:164)
	at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:316)
	at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:106)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
	at org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
	at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
	at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
	at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
	at java.lang.Thread.run(Thread.java:595)


Kind regards
Matthias



Mime
View raw message