Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.3
    • Component/s: Components/Renderers
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      807
    • Status Whiteboard:
      Hide

      size_small importance_medium

      Show
      size_small importance_medium

      Description

      Reviewing some stuff, it was notice that the FacesContext instance is not passed
      when event processing occur, so every time a system event should be processed, a
      call to FacesContext.getCurrentInstance() should be done in almost all cases.

      Below there are one example based on myfaces code (removed non relevant code):

      public class HtmlStylesheetRenderer extends Renderer implements
      ComponentSystemEventListener
      {

      public void processEvent(ComponentSystemEvent event)

      { UIComponent component = event.getComponent(); FacesContext facesContext = FacesContext.getCurrentInstance(); facesContext.getViewRoot().addComponentResource(facesContext, component, "head"); }

      ......
      }

      It could be good to pass the current facesContext (note the code in
      Application.publishEvent receive it as param), to prevent those unnecessary
      calls and enhance code performance. In theory it is possible to cache
      facesContext object on listeners suscribed using
      UIViewRoot.subscribeToViewEvent() because those listeners are not saved (but
      maybe not because if the same view is used on portlet....), but that's not
      possible on ComponentSystemEventListener instances.

        Issue Links

          Activity

          Hide
          Hanspeter Duennenberger added a comment -

          If FacesContext would be passed on all FacesEvent/SystemEvent objects, every
          listener would have access to the current FacesContext from FacesEvent.

          Thus the below code would look like:

          public void processEvent(ComponentSystemEvent event)

          { UIComponent component = event.getComponent(); FacesContext facesContext = event.getFacesContext(); facesContext.getViewRoot().addComponentResource(facesContext, component, "head"); }
          Show
          Hanspeter Duennenberger added a comment - If FacesContext would be passed on all FacesEvent/SystemEvent objects, every listener would have access to the current FacesContext from FacesEvent. Thus the below code would look like: public void processEvent(ComponentSystemEvent event) { UIComponent component = event.getComponent(); FacesContext facesContext = event.getFacesContext(); facesContext.getViewRoot().addComponentResource(facesContext, component, "head"); }
          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.
          Hide
          Manfred Riem added a comment -

          Setting priority to Major

          Show
          Manfred Riem added a comment - Setting priority to Major
          Hide
          Manfred Riem added a comment -

          Setting priority to Critical

          Show
          Manfred Riem added a comment - Setting priority to Critical
          Hide
          Manfred Riem added a comment -

          Applied to 2.3 trunk,

          svn commit -m "Fixes https://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-807, Need to pass FacesContext instance to system event listeners"
          Sending jsf-api/src/main/java/javax/faces/event/ComponentSystemEvent.java
          Sending jsf-api/src/main/java/javax/faces/event/ExceptionQueuedEvent.java
          Sending jsf-api/src/main/java/javax/faces/event/PostAddToViewEvent.java
          Sending jsf-api/src/main/java/javax/faces/event/PostConstructApplicationEvent.java
          Sending jsf-api/src/main/java/javax/faces/event/PostConstructCustomScopeEvent.java
          Sending jsf-api/src/main/java/javax/faces/event/PostConstructViewMapEvent.java
          Sending jsf-api/src/main/java/javax/faces/event/PostKeepFlashValueEvent.java
          Sending jsf-api/src/main/java/javax/faces/event/PostPutFlashValueEvent.java
          Sending jsf-api/src/main/java/javax/faces/event/PostRenderViewEvent.java
          Sending jsf-api/src/main/java/javax/faces/event/PostRestoreStateEvent.java
          Sending jsf-api/src/main/java/javax/faces/event/PostValidateEvent.java
          Sending jsf-api/src/main/java/javax/faces/event/PreClearFlashEvent.java
          Sending jsf-api/src/main/java/javax/faces/event/PreDestroyApplicationEvent.java
          Sending jsf-api/src/main/java/javax/faces/event/PreDestroyCustomScopeEvent.java
          Sending jsf-api/src/main/java/javax/faces/event/PreDestroyViewMapEvent.java
          Sending jsf-api/src/main/java/javax/faces/event/PreRemoveFlashValueEvent.java
          Sending jsf-api/src/main/java/javax/faces/event/PreRemoveFromViewEvent.java
          Sending jsf-api/src/main/java/javax/faces/event/PreRenderComponentEvent.java
          Sending jsf-api/src/main/java/javax/faces/event/PreRenderViewEvent.java
          Sending jsf-api/src/main/java/javax/faces/event/PreValidateEvent.java
          Sending jsf-api/src/main/java/javax/faces/event/SystemEvent.java
          Transmitting file data .....................
          Committed revision 15107.

          Show
          Manfred Riem added a comment - Applied to 2.3 trunk, svn commit -m "Fixes https://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-807 , Need to pass FacesContext instance to system event listeners" Sending jsf-api/src/main/java/javax/faces/event/ComponentSystemEvent.java Sending jsf-api/src/main/java/javax/faces/event/ExceptionQueuedEvent.java Sending jsf-api/src/main/java/javax/faces/event/PostAddToViewEvent.java Sending jsf-api/src/main/java/javax/faces/event/PostConstructApplicationEvent.java Sending jsf-api/src/main/java/javax/faces/event/PostConstructCustomScopeEvent.java Sending jsf-api/src/main/java/javax/faces/event/PostConstructViewMapEvent.java Sending jsf-api/src/main/java/javax/faces/event/PostKeepFlashValueEvent.java Sending jsf-api/src/main/java/javax/faces/event/PostPutFlashValueEvent.java Sending jsf-api/src/main/java/javax/faces/event/PostRenderViewEvent.java Sending jsf-api/src/main/java/javax/faces/event/PostRestoreStateEvent.java Sending jsf-api/src/main/java/javax/faces/event/PostValidateEvent.java Sending jsf-api/src/main/java/javax/faces/event/PreClearFlashEvent.java Sending jsf-api/src/main/java/javax/faces/event/PreDestroyApplicationEvent.java Sending jsf-api/src/main/java/javax/faces/event/PreDestroyCustomScopeEvent.java Sending jsf-api/src/main/java/javax/faces/event/PreDestroyViewMapEvent.java Sending jsf-api/src/main/java/javax/faces/event/PreRemoveFlashValueEvent.java Sending jsf-api/src/main/java/javax/faces/event/PreRemoveFromViewEvent.java Sending jsf-api/src/main/java/javax/faces/event/PreRenderComponentEvent.java Sending jsf-api/src/main/java/javax/faces/event/PreRenderViewEvent.java Sending jsf-api/src/main/java/javax/faces/event/PreValidateEvent.java Sending jsf-api/src/main/java/javax/faces/event/SystemEvent.java Transmitting file data ..................... Committed revision 15107.

            People

            • Assignee:
              Manfred Riem
              Reporter:
              lu4242
            • Votes:
              2 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: