users@glassfish.java.net

IE Redirect results in early response commit when using Browser Back button

From: <glassfish_at_javadesktop.org>
Date: Tue, 27 Feb 2007 11:18:37 PST

I'm using JSF RI 1.1_01 and got the following issue only on IE.

Here is my navigation rules
<navigation-rule>
    <description>
      Navigation rule for all JSF pages.
    </description>
    <from-view-id>*</from-view-id>
    <navigation-case>
      <from-outcome>page1</from-outcome>
      <to-view-id>/Page1.jsp</to-view-id>
      <redirect/>
    </navigation-case>
    <navigation-case>
      <from-outcome>page2</from-outcome>
      <to-view-id>/Page2.jsp</to-view-id>
      <redirect/>
    </navigation-case>
    <navigation-case>
      <from-outcome>page3</from-outcome>
      <to-view-id>/Page3.jsp</to-view-id>
      <redirect/>
    </navigation-case>
</navigation-rule>

In Page1.jsp, there is a command link that goes to Page2.jsp and a command button with an action method that goes to Page3.jsp. I'm using client save state method.

When I click the link on Page 1, it goes to Page 2. Then I click the browser's back button and click the button on Page 1. I expect to go to Page 3. It works on FireFox. However on IE, I got the following exception instead:

===============

java.lang.IllegalStateException
        org.apache.catalina.connector.ResponseFacade.sendRedirect(ResponseFacade.java:432)
        com.sun.faces.context.ExternalContextImpl.redirect(ExternalContextImpl.java:333)
        com.fonemine.webui.jsf.navigation.FmNavigationHandler.handleNavigation(FmNavigationHandler.java:92)
        com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:89)
        javax.faces.component.UICommand.broadcast(UICommand.java:312)
        javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
        javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:307)
        com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:79)
        com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
        com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
        javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
        com.fonemine.webui.upload.UploadMultipartFilter.doFilter(UploadMultipartFilter.java:67)

=================

I am able to track down this issue and get to the code inside NavigationHandler. The issue is that by the time NavigationHandler.handleNavigation() is called, facesContext.getResponseComplete() is true in IE (but false when using FireFox!!!). In an attempt to fix the issue, I use a custom NavigationHandler which overwrite the handleNavigation to check for getResponseComplete() and call the default NavigationHandler's handleNavigation() method.

The result of that is the exception is gone. However, instead of going to Page3 when clicking on Page1's button, it goes to Page2.

Does anyone know how can I fix this issue without upgrading to JSF 1.2 (I'm not sure if this got fix in JSF 1.2 but I cannot afford to upgrade to 1.2)

Thanks in advance for any help,
Edmond
[Message sent by forum member 'chihin' (chihin)]

http://forums.java.net/jive/thread.jspa?messageID=205522