0 Replies Latest reply on Dec 15, 2007 8:46 AM by lukas.eder

    Potential flaw in AjaxStateManager

    lukas.eder

      In method

      restoreStateFromSession(FacesContext, String, String)
      , there seems to be a problem with restoring the last saved state on lines 285 and 293. The log messages above each of the lines explicitly states that the LAST state should be restored. However, the code restores the first state.

      I changed both statements
      logicalStates.firstKey()
      to
      logicalStates.lastKey()
      and could finally start to work after several days of debugging until I found this flaw. This is the code snipped I tested against:

      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
      <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
      <%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
      <f:view>
      <a4j:page id="page" pageTitle="desperate">
      <h:form id="reloadForm">
      <rich:tabPanel id="panel" switchType="server" value="First">
      <rich:tab id="First" name="First" label="First">
      <h:commandLink id="link1" actionListener="#{tb.printHelloA}">
      <h:outputText value="Link A" />
      </h:commandLink>
      </rich:tab>
      <rich:tab id="Second" name="Second" label="Second">
      <h:commandLink id="link2" actionListener="#{tb.printHelloB}">
      <h:outputText value="Link B" />
      </h:commandLink>
      </rich:tab>
      </rich:tabPanel>
      </h:form>
      </a4j:page>
      </f:view>


      Without the fix, clicking on the second tab and then on link B sometimes resulted in switching back to the first tab and action tb.printHelloB not being executed. With the fix, everything worked fine.

      After all these days of debugging, I hope my assumption is true and I could help make this world a better place :-)

      PS: I am referring to rich faces 3.1.2.GA