1 Reply Latest reply on Jul 16, 2007 12:55 PM by Jay Lin

    Back button and Ajax form submission throw ClassCastExceptio

    Jay Lin Newbie

      Gurus,

      I had been using ajax4jsf for basic purpose of drilling down select menus and Ajax4jsf worked as it was advertised, but I noticed a bug in our testing phrase.

      Here are some background info of our application setup:

      We have an application sign up process broken down to multiple pages using session scope. On one of the page we used Ajax4jsf to drill down menu selections. The application works without any issue if the users follow as clearly directed. The error arise when the user click on the back button to go back to page with ajax4jsf embedded and submit the form.

      Here is the stack trace for this error:

      java.lang.ClassCastException: org.ajax4jsf.framework.ajax.AjaxViewRoot
       at com.sun.faces.application.StateManagerImpl.restoreTree(StateManagerImpl.java:607)
       at com.sun.faces.application.StateManagerImpl.restoreView(StateManagerImpl.java:166)
       at org.ajax4jsf.framework.ajax.AjaxStateManager.restoreView(AjaxStateManager.java:83)
       at com.sun.faces.application.ViewHandlerImpl.restoreView(ViewHandlerImpl.java:256)
       at com.sun.facelets.FaceletViewHandler.restoreView(FaceletViewHandler.java:317)
       at org.ajax4jsf.framework.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:116)
       at org.ajax4jsf.framework.ajax.AjaxViewHandler.restoreView(AjaxViewHandler.java:147)
       at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:129)
       at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:243)
       at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:113)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:96)
       at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:220)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at dma.universal.filters.RecruiterReferralFilter.doFilter(RecruiterReferralFilter.java:35)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at dma.vista.db.HibernateFilter.doFilter(HibernateFilter.java:46)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at dma.universal.filters.SignupProcessFilter.doFilter(SignupProcessFilter.java:50)
       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:868)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
       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)
      



      I am using server side state saving method with Facelets. And here are the excerpt from my xhtml page:


       <tr>
       <td style="text-align: right">
       City:<h:inputText id="CityId" size="15"
       value="#{beanName.empCity}" /></td>
       <td>
       <a4j:region renderRegionOnly="true">
      
       <h:selectOneMenu styleClass="inputControl2" id="countries" required="true" requiredMessage="Country is required"
       value="#{beanName.empCountry}">
       <f:selectItem itemValue="" itemLabel="Country:" />
       <f:selectItems value="#{beanName.countries}" />
       <a4j:support event="onchange"
       action="#{beanName.changeStateList}" immediate="true"
       onsubmit="document.getElementById('indicator_geo').style.display = 'inline';"
       oncomplete="checkCountry();document.getElementById('indicator_geo').style.display = 'none';"
       ajaxSingle="true"
       reRender="statesProvinces" />
       </h:selectOneMenu>
       <h:selectOneMenu styleClass="inputControl2"
       value="#{beanName.empState}" id="statesProvinces">
       <f:selectItem itemValue="" itemLabel="State/Province:" />
       <f:selectItems value="#{beanName.statesAndProvinces}" />
       </h:selectOneMenu>
       </a4j:region><img style="display: none;" id="indicator_geo" src="#{facesContext.externalContext.requestContextPath}/images/indicator.gif"/></td>
       </tr>
      



      Many thanks in advance,


      Jay