ICEfaces
  1. ICEfaces
  2. ICE-5594

Make sure only one view state key is generate per page load

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-Alpha2
    • Fix Version/s: 2.0-Alpha3, 2.0.0
    • Component/s: Framework
    • Labels:
      None
    • Environment:
      server

      Description

       To avoid any subtle issues in the future we need to make sure only one view state key is generate per page load. Right now, during page load, com.sun....FormRender and BridgeSetup generate a view state key by calling StateManager.getViewState method. When the view is handled by ICEfaces it will modify the forms within the page to use the key generated by the form renderer.

        Activity

        Hide
        Ted Goddard added a comment -

        Currently the script UIOutput components are prepared with the static value of the ViewState key at the time they are added to the component tree. It should be possible to create a UIOutput that dynamically produces its value from the ViewState key at the time of rendering. (It is still possible for the component tree to be altered during the render phase, but the risk is at least reduced.)

        It may also make sense to allow a mode where the value is looked up in the browser from javax.faces.ViewState. This would work well in the Servlet case when forms are present, so could be the default mode.

        Show
        Ted Goddard added a comment - Currently the script UIOutput components are prepared with the static value of the ViewState key at the time they are added to the component tree. It should be possible to create a UIOutput that dynamically produces its value from the ViewState key at the time of rendering. (It is still possible for the component tree to be altered during the render phase, but the risk is at least reduced.) It may also make sense to allow a mode where the value is looked up in the browser from javax.faces.ViewState. This would work well in the Servlet case when forms are present, so could be the default mode.
        Hide
        Mircea Toma added a comment -

        It seems that the default JSF state manager will not return the same view state key when StateManager.getViewState method is invoked multiple times during the page load (not postaback). This means that the view state key cannot be accessed programmatically on the server side.

        Both ice.singleSubmit and ice.retrieveUpdate functions need a valid view state key which should be the same with the key the forms receive when they are rendered (they receive it through a complicated mechanism – see com.sun.faces.application.ViewHandlerImpl$WriteBehindStateWriter). To solve this without having to write any code that would depend on com.sun.faces.* classes we always append a UIForm component to the component tree. This way the there is always a form that can be looked up on the client side to use its view state key.
        The appended form, as a convention, has its ID value the same with the generated viewID. When ice.singleSubmit is invoked it will lookup the form based on this ID an use it to send event data along with the correct javax.faces.ViewState value (already included in the form). ice.ice.retrieveUpdate uses the viewID as pushID, it too can lookup easily the form and use it as well to initiate a request that uses the proper view state key.

        Show
        Mircea Toma added a comment - It seems that the default JSF state manager will not return the same view state key when StateManager.getViewState method is invoked multiple times during the page load (not postaback). This means that the view state key cannot be accessed programmatically on the server side. Both ice.singleSubmit and ice.retrieveUpdate functions need a valid view state key which should be the same with the key the forms receive when they are rendered (they receive it through a complicated mechanism – see com.sun.faces.application.ViewHandlerImpl$WriteBehindStateWriter). To solve this without having to write any code that would depend on com.sun.faces.* classes we always append a UIForm component to the component tree. This way the there is always a form that can be looked up on the client side to use its view state key. The appended form, as a convention, has its ID value the same with the generated viewID. When ice.singleSubmit is invoked it will lookup the form based on this ID an use it to send event data along with the correct javax.faces.ViewState value (already included in the form). ice.ice.retrieveUpdate uses the viewID as pushID, it too can lookup easily the form and use it as well to initiate a request that uses the proper view state key.
        Hide
        Mircea Toma added a comment -

        Simplified ICEpush setup on client side to reduce the amount of markup.

        Show
        Mircea Toma added a comment - Simplified ICEpush setup on client side to reduce the amount of markup.

          People

          • Assignee:
            Mircea Toma
            Reporter:
            Mircea Toma
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: