ICEfaces
  1. ICEfaces
  2. ICE-5211

Gmap doesn't work under compat

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-Alpha1
    • Fix Version/s: 2.0-Beta2, 2.0.0
    • Component/s: ICE-Components
    • Labels:
      None
    • Environment:
      Gmap
    • Affects:
      Documentation (User Guide, Ref. Guide, etc.), Sample App./Tutorial

      Description

      Joanne Bai wrote:
      > Glimmer/Compat revision #19959
      > Server tested: Tomcat 6
      > Browser tested: FF3.5


      >Components that are not available at all

      >- File Upload
      >- Google Map
      >- Data Exporter

        Issue Links

          Activity

          Hide
          Adnan Durrani added a comment -

          It come across that GMap component breaks and throw the following exception only when it gets rendered dynamically. If its the GMap component is a part of Initial rendering then it works fine.

          javax.faces.FacesException: Unexpected error restoring state for component with id javax_faces_locat
          ion_HEAD. Cause: java.lang.ClassCastException: com.sun.faces.application.view.StateHolderSaver.
          at com.sun.faces.application.view.StateManagementStrategyImpl$2.visit(StateManagementStrateg
          yImpl.java:240)
          at com.sun.faces.component.visit.FullVisitContext.invokeVisitCallback(FullVisitContext.java:
          147)
          at javax.faces.component.UIComponent.visitTree(UIComponent.java:1443)
          at javax.faces.component.UIComponent.visitTree(UIComponent.java:1454)
          at com.sun.faces.application.view.StateManagementStrategyImpl.restoreView(StateManagementStr
          ategyImpl.java:224)
          at com.sun.faces.application.StateManagerImpl.restoreView(StateManagerImpl.java:177)
          at com.sun.faces.application.view.ViewHandlingStrategy.restoreView(ViewHandlingStrategy.java
          :131)
          at com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(FaceletViewHandlin
          gStrategy.java:429)
          at com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:143)
          at javax.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:288)
          at javax.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:288)
          at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:199)
          at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
          at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:110)
          at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
          at javax.faces.webapp.FacesServlet.service(FacesServlet.java:310)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.j
          ava:290)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.ja
          va:584)
          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
          at java.lang.Thread.run(Thread.java:595)

          Show
          Adnan Durrani added a comment - It come across that GMap component breaks and throw the following exception only when it gets rendered dynamically. If its the GMap component is a part of Initial rendering then it works fine. javax.faces.FacesException: Unexpected error restoring state for component with id javax_faces_locat ion_HEAD. Cause: java.lang.ClassCastException: com.sun.faces.application.view.StateHolderSaver. at com.sun.faces.application.view.StateManagementStrategyImpl$2.visit(StateManagementStrateg yImpl.java:240) at com.sun.faces.component.visit.FullVisitContext.invokeVisitCallback(FullVisitContext.java: 147) at javax.faces.component.UIComponent.visitTree(UIComponent.java:1443) at javax.faces.component.UIComponent.visitTree(UIComponent.java:1454) at com.sun.faces.application.view.StateManagementStrategyImpl.restoreView(StateManagementStr ategyImpl.java:224) at com.sun.faces.application.StateManagerImpl.restoreView(StateManagerImpl.java:177) at com.sun.faces.application.view.ViewHandlingStrategy.restoreView(ViewHandlingStrategy.java :131) at com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(FaceletViewHandlin gStrategy.java:429) at com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:143) at javax.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:288) at javax.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:288) at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:199) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:110) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:310) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.j ava:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.ja va:584) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Thread.java:595)
          Hide
          Adnan Durrani added a comment -

          This problem may exist in stock JSF as well. Where a component that adds a resource using ViewRoot().addComponentResource() can break when it renders dynamically.

          What I found is that:

          • UIComponentBase.restoreState(FacesContext context, Object state) casts the passed "state" object into an object array and expecting it to be an object array, but it came across that if the GMap being rendered dynamically then the "state" object happend to be an instance of "StateHolderSaver", that is causing class cast exception.

          restoreState(FacesContext context, Object state) {
          values = (Object[]) state;

          • If the GMap component is part of the initial view, then the JSF invokes the following method when GMap adds resource to the viewRoot, but this method never gets called if the GMap was rendered dynamically.
            com.sun.faces.application.view.StateManagementStrategyImpl.handleAddEvent(PostAddToViewEvent event) ;

          The above method does the bunch of things including setting the following attribute on the resource being added:
          com.sun.faces.application.view.DYNAMIC_COMPONENT

          So when com.sun.faces.application.view.StateManagementStrategyImpl.restoreView() gets called, it skips the restoreState on dynamic components.

          if (stateObj != null && !target.getAttributes().containsKey(DYNAMIC_COMPONENT))
          target.restoreState(context.getFacesContext(), stateObj);

          So when the GMap was rendered dynamically, the DYNAMIC_COMPONENT attribute was never set on the added resource and that is why restoreView() thinks that it is not a dynamic component and tries to invoke UIComponnet.restoreState() on it, and restoreState tries to cast the statObject into an object array, but founds it to be a instance of StateHolderSaver.

          Show
          Adnan Durrani added a comment - This problem may exist in stock JSF as well. Where a component that adds a resource using ViewRoot().addComponentResource() can break when it renders dynamically. What I found is that: UIComponentBase.restoreState(FacesContext context, Object state) casts the passed "state" object into an object array and expecting it to be an object array, but it came across that if the GMap being rendered dynamically then the "state" object happend to be an instance of "StateHolderSaver", that is causing class cast exception. restoreState(FacesContext context, Object state) { values = (Object[]) state; If the GMap component is part of the initial view, then the JSF invokes the following method when GMap adds resource to the viewRoot, but this method never gets called if the GMap was rendered dynamically. com.sun.faces.application.view.StateManagementStrategyImpl.handleAddEvent(PostAddToViewEvent event) ; The above method does the bunch of things including setting the following attribute on the resource being added: com.sun.faces.application.view.DYNAMIC_COMPONENT So when com.sun.faces.application.view.StateManagementStrategyImpl.restoreView() gets called, it skips the restoreState on dynamic components. if (stateObj != null && !target.getAttributes().containsKey(DYNAMIC_COMPONENT)) target.restoreState(context.getFacesContext(), stateObj); So when the GMap was rendered dynamically, the DYNAMIC_COMPONENT attribute was never set on the added resource and that is why restoreView() thinks that it is not a dynamic component and tries to invoke UIComponnet.restoreState() on it, and restoreState tries to cast the statObject into an object array, but founds it to be a instance of StateHolderSaver.
          Hide
          Adnan Durrani added a comment -

          Ted Goddard wrote:
          >
          > This may be fixed in a trunk build of JSF:
          >
          > https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1427

          Show
          Adnan Durrani added a comment - Ted Goddard wrote: > > This may be fixed in a trunk build of JSF: > > https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1427
          Hide
          Adnan Durrani added a comment -

          I tried JSF nightly build and didn't see any fix, Ted found out that JSF guy never made any commit yet. However in JSF's bug post, someone mentioned that this problem can be resolved if use the following parameter:

          <context-param>
          <param-name>javax.faces.FULL_STATE_SAVING_VIEW_IDS</param-name>
          <param-value>/showcase.xhtml</param-value>
          </context-param>

          I have tried it under component-showcase and GMap worked but now throws some other exception.

          It seems like the JSF fix could fix this problem.

          Show
          Adnan Durrani added a comment - I tried JSF nightly build and didn't see any fix, Ted found out that JSF guy never made any commit yet. However in JSF's bug post, someone mentioned that this problem can be resolved if use the following parameter: <context-param> <param-name>javax.faces.FULL_STATE_SAVING_VIEW_IDS</param-name> <param-value>/showcase.xhtml</param-value> </context-param> I have tried it under component-showcase and GMap worked but now throws some other exception. It seems like the JSF fix could fix this problem.
          Hide
          Adnan Durrani added a comment -

          Apparently the cause of this issue is due to the following issue exist in JSF. So for temporary fix we commented out the resource loading from the GMap, and now application is responsible to load the GMap API.

          https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1427

          Modified: D:\work\development\head\svn\ossrepo\icefaces\scratchpads\glimmer\compat\components\src\main\java\com\icesoft\faces\component\gmap\GMap.java
          Modified: D:\work\development\head\svn\ossrepo\icefaces\scratchpads\glimmer\compat\samples\component-showcase\web\WEB-INF\includes\templates\page-template.xhtml
          Sending content: D:\work\development\head\svn\ossrepo\icefaces\scratchpads\glimmer\compat\components\src\main\java\com\icesoft\faces\component\gmap\GMap.java
          Sending content: D:\work\development\head\svn\ossrepo\icefaces\scratchpads\glimmer\compat\samples\component-showcase\web\WEB-INF\includes\templates\page-template.xhtml
          Completed: At revision: 20004

          Show
          Adnan Durrani added a comment - Apparently the cause of this issue is due to the following issue exist in JSF. So for temporary fix we commented out the resource loading from the GMap, and now application is responsible to load the GMap API. https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=1427 Modified: D:\work\development\head\svn\ossrepo\icefaces\scratchpads\glimmer\compat\components\src\main\java\com\icesoft\faces\component\gmap\GMap.java Modified: D:\work\development\head\svn\ossrepo\icefaces\scratchpads\glimmer\compat\samples\component-showcase\web\WEB-INF\includes\templates\page-template.xhtml Sending content: D:\work\development\head\svn\ossrepo\icefaces\scratchpads\glimmer\compat\components\src\main\java\com\icesoft\faces\component\gmap\GMap.java Sending content: D:\work\development\head\svn\ossrepo\icefaces\scratchpads\glimmer\compat\samples\component-showcase\web\WEB-INF\includes\templates\page-template.xhtml Completed: At revision: 20004
          Hide
          Ken Fyten added a comment -

          We have reason to believe that a workaround for the JSF bug added in Beta1 may resolve this, so need to add the resource loading back into the component to test/verify.

          Show
          Ken Fyten added a comment - We have reason to believe that a workaround for the JSF bug added in Beta1 may resolve this, so need to add the resource loading back into the component to test/verify.
          Hide
          Judy Guglielmin added a comment -

          with the attempt to load the javascript in the constructor of Gmap(), problems occur within icefaces-compat.js at the following line:-

          new ActiveXObject('Microsoft.XMLHTTP');

          as well as getting state saving issue (as reported by Adnan above). that's just in loading the application itselft. Can step over that and then why trying to load gmap page get the following:-

          com.sun.faces.application.view.StateHolderSaver
          class java.lang.ClassCastException

          switched to try and load from "head" to "body", but still got same exception.

          Try to load the script tag in the Renderer, but what happens if you have multiple gmap components on same page?

          Show
          Judy Guglielmin added a comment - with the attempt to load the javascript in the constructor of Gmap(), problems occur within icefaces-compat.js at the following line:- new ActiveXObject('Microsoft.XMLHTTP'); as well as getting state saving issue (as reported by Adnan above). that's just in loading the application itselft. Can step over that and then why trying to load gmap page get the following:- com.sun.faces.application.view.StateHolderSaver class java.lang.ClassCastException switched to try and load from "head" to "body", but still got same exception. Try to load the script tag in the Renderer, but what happens if you have multiple gmap components on same page?
          Hide
          Judy Guglielmin added a comment -

          server exception:-

          javax.faces.FacesException: Unexpected error restoring state for component with id javax_faces_location_BODY. Cause: java.lang.ClassCastException: com.sun.faces.application.view.StateHolderSaver.
          at com.sun.faces.application.view.StateManagementStrategyImpl$1.visit(StateManagementStrategyImpl.java:250)
          at com.sun.faces.component.visit.FullVisitContext.invokeVisitCallback(FullVisitContext.java:147)
          at javax.faces.component.UIComponent.visitTree(UIComponent.java:1476)
          at javax.faces.component.UIComponent.visitTree(UIComponent.java:1487)
          at com.sun.faces.application.view.StateManagementStrategyImpl.restoreView(StateManagementStrategyImpl.java:234)
          at com.sun.faces.application.StateManagerImpl.restoreView(StateManagerImpl.java:177)
          at com.sun.faces.application.view.ViewHandlingStrategy.restoreView(ViewHandlingStrategy.java:119)
          at com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(FaceletViewHandlingStrategy.java:438)
          at com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:144)
          at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:182)
          at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)
          at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:107)
          at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114)
          at javax.faces.webapp.FacesServlet.service(FacesServlet.java:308)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
          at java.lang.Thread.run(Thread.java:613)
          Caused by: java.lang.ClassCastException: com.sun.faces.application.view.StateHolderSaver
          at javax.faces.component.UIComponentBase.restoreState(UIComponentBase.java:1422)
          at com.sun.faces.application.view.StateManagementStrategyImpl$1.visit(StateManagementStrategyImpl.java:242)
          ... 25 more

          Show
          Judy Guglielmin added a comment - server exception:- javax.faces.FacesException: Unexpected error restoring state for component with id javax_faces_location_BODY. Cause: java.lang.ClassCastException: com.sun.faces.application.view.StateHolderSaver. at com.sun.faces.application.view.StateManagementStrategyImpl$1.visit(StateManagementStrategyImpl.java:250) at com.sun.faces.component.visit.FullVisitContext.invokeVisitCallback(FullVisitContext.java:147) at javax.faces.component.UIComponent.visitTree(UIComponent.java:1476) at javax.faces.component.UIComponent.visitTree(UIComponent.java:1487) at com.sun.faces.application.view.StateManagementStrategyImpl.restoreView(StateManagementStrategyImpl.java:234) at com.sun.faces.application.StateManagerImpl.restoreView(StateManagerImpl.java:177) at com.sun.faces.application.view.ViewHandlingStrategy.restoreView(ViewHandlingStrategy.java:119) at com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(FaceletViewHandlingStrategy.java:438) at com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:144) at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:182) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97) at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:107) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:308) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at java.lang.Thread.run(Thread.java:613) Caused by: java.lang.ClassCastException: com.sun.faces.application.view.StateHolderSaver at javax.faces.component.UIComponentBase.restoreState(UIComponentBase.java:1422) at com.sun.faces.application.view.StateManagementStrategyImpl$1.visit(StateManagementStrategyImpl.java:242) ... 25 more
          Hide
          Ken Fyten added a comment -

          For Gmap compat, need to inject it's external JS link in the body section when it is rendered to the page. This technique also needs to ensure that it is only added once per page, so first one wins, and the subsequent gmaps just check to see if the link is already there (and then do not add it again themselves).

          Show
          Ken Fyten added a comment - For Gmap compat, need to inject it's external JS link in the body section when it is rendered to the page. This technique also needs to ensure that it is only added once per page, so first one wins, and the subsequent gmaps just check to see if the link is already there (and then do not add it again themselves).
          Hide
          Judy Guglielmin added a comment -

          the problem with state-saving is the component.addResource call, so remove it and just add script tag.
          However, in the GMap class, encodeBegin(), this just puts the tag within the gmap container and for it to be loaded, the script tag needs to be closed before the beginning of the gmap container. Will try to do this in the renderer class before using a script renderer which listens for the gmap class (using ComponentSystemEventListener)

          Show
          Judy Guglielmin added a comment - the problem with state-saving is the component.addResource call, so remove it and just add script tag. However, in the GMap class, encodeBegin(), this just puts the tag within the gmap container and for it to be loaded, the script tag needs to be closed before the beginning of the gmap container. Will try to do this in the renderer class before using a script renderer which listens for the gmap class (using ComponentSystemEventListener)
          Hide
          Ken Fyten added a comment -

          Fixed.

          Show
          Ken Fyten added a comment - Fixed.

            People

            • Assignee:
              Judy Guglielmin
              Reporter:
              Adnan Durrani
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: