The below api is a little gross, but I don't see a better solution to the problem.

-- Blake Sullivan

-------- Original Message --------
Subject: [jira] Created: (TRINIDAD-2067) setUpEncodingContext called twice on all partial page rendered roots during optimized PPR
Date:   Fri, 18 Mar 2011 01:32:29 +0000 (UTC)
From:   Blake Sullivan (JIRA) <dev@myfaces.apache.org>
Reply-To:       MyFaces Development <dev@myfaces.apache.org>
To:     dev@myfaces.apache.org



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

                 Key: TRINIDAD-2067
                 URL: https://issues.apache.org/jira/browse/TRINIDAD-2067
             Project: MyFaces Trinidad
          Issue Type: Bug
          Components: Archetype
    Affects Versions: 2.0.0-beta-3
            Reporter: Blake Sullivan
            Assignee: Blake Sullivan


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.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to