You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by Apache Wiki <wi...@apache.org> on 2007/12/04 20:49:26 UTC

[Tapestry Wiki] Trivial Update of "RecursiveComponents" by GregWoolsey

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Tapestry Wiki" for change notification.

The following page has been changed by GregWoolsey:
http://wiki.apache.org/tapestry/RecursiveComponents

------------------------------------------------------------------------------
  
  Example 2 is cleaner, but not a working example - their code has typos, and doesn't mention a very important caveat.  This example uses a component level property to hold the child object For component iteration value.  This appears fine, but the For component does (or doesn't do) something not documented - it doesn't remember and reset the state of the property used for the value and index bindings before and after iterating over the source values.  This means that any recursive Block body contents that reference this component level property after the recursive For component has used it for it's value binding will see not the value of the property in the expected scope.
  
- This is quite confusing, and took me a while to figure out.  The problem relates to how OGNL evaluates references and the fact that the sample needs a component property to store the child For value object passed to the recursive RenderBlock call.  Each level of Block rendering looks for it's input data via `getProperty()`, which is defined in terms of the For component value binding, which is set to the component property.  There is only one instance of the component property for the whole recursive rendering, and the default behavior of the For component results in that property remaining set to the last value found in the last iteration of the lowest level of recursion once the recursive calls start to unwind.  
+ This is quite confusing, and took me a while to figure out.  The problem relates to how OGNL evaluates references and the fact that the sample needs a component property to store the child For value object passed to the recursive `RenderBlock` call.  Each level of Block rendering looks for it's input data via `getProperty()`, which is defined in terms of the For component value binding, which is set to the component property.  There is only one instance of the component property for the whole recursive rendering, and the default behavior of the For component results in that property remaining set to the last value found in the last iteration of the lowest level of recursion once the recursive calls start to unwind.  
  
  Thus components in the Block body after the recursive For component do not see the Block input parameter for that block's original call, but the last value the underlying component property was set to by the last iteration of the lowest recursion.
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org