javaserverfaces-spec-public
  1. javaserverfaces-spec-public
  2. JAVASERVERFACES_SPEC_PUBLIC-792

Cannot call UIComponent.getCurrentComponent() from UIComponent.restoreState() or UIComponent.saveState()

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.0
    • Fix Version/s: None
    • Component/s: Components/Renderers
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      792
    • Status Whiteboard:
      Hide

      size_medium importance_large

      Show
      size_medium importance_large
    • Tags:

      Description

      From jsr-314-open list:

      The javadoc of UIComponent.processRestoreState() says this:

      "....Perform the component tree processing required by the Restore View phase
      of the request processing lifecycle for all facets of this component, all
      children of this component, and this component itself, as follows.

      • Call the restoreState() method of this component.
      • Call pushComponentToEL(javax.faces.context.FacesContext,
        javax.faces.component.UIComponent).
      • Call the processRestoreState() method of all facets and children of this
        UIComponent in the order determined by a call to getFacetsAndChildren(). After
        returning from the processRestoreState() method on a child or facet, call
        popComponentFromEL(javax.faces.context.FacesContext)..."

      The javadoc of UIComponent.processSaveState() says this:

      ".....Perform the component tree processing required by the state saving portion
      of the Render Response phase of the request processing lifecycle for all facets
      of this component, all children of this component, and this component itself, as
      follows.

      • consult the transient property of this component. If true, just return null.
      • Call pushComponentToEL(javax.faces.context.FacesContext,
        javax.faces.component.UIComponent).
      • Call the processSaveState() method of all facets and children of this
        UIComponent in the order determined by a call to getFacetsAndChildren(),
        skipping children and facets that are transient. Ensure that
        popComponentFromEL(javax.faces.context.FacesContext) is called correctly after
        each child or facet.
      • Call the saveState() method of this component.
      • Encapsulate the child state and your state into a Serializable Object and
        return it....."

      The question is: Doesn't suppose that when you call
      UIComponent.getCurrentComponent() inside UIComponent.restoreState(), it returns
      the "current component"?. There is one case when we need to do this call and is
      on the wrapper used by UIComponent.subscribeToEvent(). The javadoc of this
      method says this:

      "....Install the listener instance referenced by argument componentListener as a
      listener for events of type eventClass originating from this specific instance
      of UIComponent. The default implementation creates an inner SystemEventListener
      instance that wraps argument componentListener as the listener argument. This
      inner class must call through to the argument componentListener in its
      implementation of
      SystemEventListener.processEvent(javax.faces.event.SystemEvent) and its
      implementation of SystemEventListener.isListenerForSource(java.lang.Object)
      must return true if the instance class of this UIComponent is assignable from
      the argument to isListenerForSource...."

      Both myfaces and mojarra has the wrapper described by the javadoc, and that one
      is responsible to save/restore the system event listeners attached. To restore
      the "component" reference required, both implementations call
      UIComponent.getCurrentComponent() and both call processEvent but for the parent!.

      It is obviously a bug (I don't see a valid reason why do the algorithm
      described), if you look other methods like processDecodes, you see the right
      pattern:

      • If the rendered property of this UIComponent is false, skip further
        processing.
      • Call pushComponentToEL(javax.faces.context.FacesContext,
        javax.faces.component.UIComponent).
      • Call the processDecodes() method of all facets and children of this
        UIComponent, in the order determined by a call to getFacetsAndChildren().
      • Call the decode() method of this component.
      • Call popComponentFromEL(javax.faces.context.FacesContext) from inside of a
        finally block, just before returning.
      • If a RuntimeException is thrown during decode processing, call
        FacesContext.renderResponse() and re-throw the exception.

      I'll change myfaces algorithm to look like processDecodes(). But anyway, it is
      necessary to do the proper change on mojarra and on spec javadoc.

        Activity

        Hide
        Ed Burns added a comment -

        GlassFish 3.1 M6 at the latest.

        Show
        Ed Burns added a comment - GlassFish 3.1 M6 at the latest.
        Hide
        Ed Burns added a comment -

        ADF issues targeted at GlassFish 3.1 M5

        Show
        Ed Burns added a comment - ADF issues targeted at GlassFish 3.1 M5
        Hide
        Ed Burns added a comment -

        2.2

        Show
        Ed Burns added a comment - 2.2
        Hide
        Ed Burns added a comment -

        2.3

        Show
        Ed Burns added a comment - 2.3
        Hide
        Ed Burns added a comment -

        Set priority to baseline ahead of JSF 2.3 triage. Priorities will be assigned accurately after this exercise.

        Show
        Ed Burns added a comment - Set priority to baseline ahead of JSF 2.3 triage. Priorities will be assigned accurately after this exercise.

          People

          • Assignee:
            Unassigned
            Reporter:
            lu4242
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: