javaserverfaces
  1. javaserverfaces
  2. JAVASERVERFACES-3205

Postback executes <f:event type="preRenderView"> listeners of another view when current view contains h:link which uses includeViewParams

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.25, 2.1.28, 2.2.5
    • Fix Version/s: 2.2.7
    • Labels:
      None
    • Environment:

      Windows 7 64-bit, Jetty

      Description

      When creating a link with an outcome that resolves to a page and using the includeViewParams, the preRenderView event of the target page will be attached to the current viewroot during the first render phase.
      On any postback of the first page, the preRenderView listener of the target page will be executed on the preRenderView event trigger of the first page. Even if the postback has nothing to do with the target page.
      In our case, the preRenderView event is used to check if the viewParams have a correct value, and an exception is thrown on any postback of the first page.

      See also https://java.net/jira/browse/JAVASERVERFACES-2158

      Attached is an example of 2 pages with 2 beans showing the issue. The first.xhtml page contains a bit of an explanation of how the problem is triggered.
      I conducted extra tests against the most recent versions of JSF 2.1 and 2.2

      It doesn't matter if you use an outcome defined in a NavigationCase in faces-config or just the name of the target view as outcome.

        Issue Links

          Activity

          Ed Burns logged work - 03/Apr/14 8:11 PM
          • Time Spent:
            1 hour, 15 minutes
             
            Committed to 2.2.x rolling.



            SECTION: Modified Files
            ----------------------------
            M jsf-ri/src/main/java/com/sun/faces/applciation/view/ViewMetadataImpl.java

            - in createMetadataView(), ensure old UIViewRoot is restored.
            Sending jsf-ri/src/main/java/com/sun/faces/application/view/ViewMetadataImpl.java
            Transmitting file data .
            Committed revision 13088.
          Ed Burns logged work - 03/Apr/14 8:27 PM
          • Time Spent:
            15 minutes
             
            Commit automated test to 2.2.x. Thanks to Ben.Winkeler for creating it!


            SECTION: Modified Files
            ----------------------------
            A test/agnostic/facelets/core/src/test/java/com/sun/faces/test/agnostic/facelets/core/Issue3205IT.java
            A test/agnostic/facelets/core/src/main/webapp/viewParamListener_second.xhtml
            A test/agnostic/facelets/core/src/main/webapp/viewParamListener_first.xhtml
            A test/agnostic/facelets/core/src/main/java/com/sun/faces/test/agnostic/facelets/core/OutcomeTestSecondBean.java
            A test/agnostic/facelets/core/src/main/java/com/sun/faces/test/agnostic/facelets/core/OutcomeTestFirstBean.java

            - New automated test.
            Adding test/agnostic/facelets/core/src/main/java/com/sun/faces/test/agnostic/facelets/core/OutcomeTestFirstBean.java
            Adding test/agnostic/facelets/core/src/main/java/com/sun/faces/test/agnostic/facelets/core/OutcomeTestSecondBean.java
            Adding test/agnostic/facelets/core/src/main/webapp/viewParamListener_first.xhtml
            Adding test/agnostic/facelets/core/src/main/webapp/viewParamListener_second.xhtml
            Adding test/agnostic/facelets/core/src/test/java/com/sun/faces/test/agnostic/facelets/core/Issue3205IT.java
            Transmitting file data .....
            Committed revision 13089.
          Ed Burns logged work - 04/Apr/14 3:33 PM
          • Time Spent:
            6 minutes
             
            Revert mod, @Ignore new test.
          Ed Burns logged work - 10/Apr/14 7:40 PM
          • Time Spent:
            1 hour, 30 minutes
             
            Committed to 2.2.x.




            SECTION: Modified Files
            ----------------------------
            M test/agnostic/facelets/core/src/test/java/com/sun/faces/test/agnostic/facelets/core/Issue3205IT.java

            - Remove @Ignore

            M jsf-ri/src/main/java/com/sun/faces/application/view/ViewMetadataImpl.java

            - Make sure to also copy the contents of the ViewMap to the temporary
              UIViewRoot.
            Sending jsf-ri/src/main/java/com/sun/faces/application/view/ViewMetadataImpl.java
            Sending test/agnostic/facelets/core/src/test/java/com/sun/faces/test/agnostic/facelets/core/Issue3205IT.java
            Transmitting file data ..
            Committed revision 13116.
          Ed Burns logged work - 11/Apr/14 6:38 PM
          • Time Spent:
            1 hour, 55 minutes
             
            Committed to 2.2.x.

            SECTION: Modified Files
            ----------------------------
            M test/agnostic/facelets/core/src/test/java/com/sun/faces/test/agnostic/facelets/core/Issue3205IT.java

            - Remove @Ignore.

            M jsf-ri/src/main/java/com/sun/faces/application/view/ViewMetadataImpl.java

            - in createMetadataView(), if there is a current UIViewRoot, ensure the
              FacesContext gets populated with the temporary UIViewRoot (complete
              with a ViewMap whose contents have been copied from the current
              UIViewRoot) before invoking the template. Also, if this UIViewRoot
              copying code executed, ensure the old UIViewRoot (and ViewMap
              contents) are restored into the FacesContext before returning.
            Sending jsf-ri/src/main/java/com/sun/faces/application/view/ViewMetadataImpl.java
            Sending test/agnostic/facelets/core/src/test/java/com/sun/faces/test/agnostic/facelets/core/Issue3205IT.java
            Transmitting file data ..
            Committed revision 13119.

            People

            • Assignee:
              Ed Burns
              Reporter:
              Ben.Winkeler
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 5 hours, 1 minute
                5h 1m