Uploaded image for project: 'MyFaces Trinidad'
  1. MyFaces Trinidad
  2. TRINIDAD-2067

setUpEncodingContext called twice on all partial page rendered roots during optimized PPR

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.0.0-core
    • 2.0.0-core
    • Archetype
    • None

    Description

      setUpEncodingContext is called on all of the partial page roots during optimized partial page rendering. This is because optimizedPPR uses a tree visit to visit the partial page roots to render and the tree visiting code calls setUpEncodingContext before calling the visit callback. The optimized PPR code then calls encodeAll() on the partial target, which calls beforeEncode(), which calls setupEncodingContext again. This breaks code that can't have its setupEncodingContext (and tearDownEncodingContext) called twice in a row. A good example is a form renderer that uses setupEncodingContext to catch cases where forms have been nested.

      The fix is to add an api to UIXComponent:

      /**

      • Calls the VisitCallback after popping the encoding or visiting context of the
      • current component and then restores that context, returning the VisitCallbacks's
      • response. This handles the rare cases where a VisitCallback should not be
      • called inside the target component's callback.
      • @param visitContext the <code>VisitContext</code> for this visit
      • @param component the <code>UIComponent</code> to pop the context of
      • @param callback the <code>VisitCallback</code> instance to call in the popped context
      • @return the result of the VisitCallback
        */
        public static VisitResult visitOutsideOfContext(
        VisitContext visitContext,
        UIComponent component,
        VisitCallback callback)

      The optimized PPR code can then wrap its current VisitCallback in one that calls visitOutsideOfContext, passing in the original VisitCallback.

      Other solutions would attempt to change the optimized PPR code to attempt to avoid calling encodeAll when the target was a UIXComponent, however doing so would require making assumptions about how different components have implemented encodeAll(), violating its abstraction.

      Attachments

        1. trin2067_2B3.patch
          5 kB
          Blake Sullivan

        Activity

          People

            btsulliv Blake Sullivan
            btsulliv Blake Sullivan
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 24h
                24h
                Remaining:
                Remaining Estimate - 24h
                24h
                Logged:
                Time Spent - Not Specified
                Not Specified