Thanks Bernard. Your template seems really straight forward. The problem I having right now is that the block that is rendered is returned via an ognl expression and the expression is only being evaluated once. Do you know a way around this?
On Wed, 2006-08-02 at 15:49 +0200, Bernard Lange wrote: > Dan Adams wrote: > > Every once in a while I'll need to do some recursive rendering. Does > > anyone know of a simple example of this using @Block? > > We do it that way. This renders tree-like, no folding though, recursive > structure of report groups containing other report groups (which are > compound nodes) and reports (leafs). Root group is given as a parameter, > but it may be as well page property with initial value set to sth. You > also need some exit condition, which in this case is size of > reportGroups property. > > Note that the group property is updated in the second loop so that the > recursive call to "groupBlock" could render its children properly. > > Some styling has been removed for a sake of readability: > > *<HTML template>* > <span jwcid="@RenderBlock" block="ognl:components.groupBlock"/> > > <block jwcid="[EMAIL PROTECTED]" > > <!-- current group name --> > <span jwcid="@Insert" value="ognl:group.name" /> > > <!-- list of children reports) --> > <loop jwcid="@Foreach" source="ognl:group.reports" > value="ognl:report" element="ul"> > > <li><span jwcid="@Insert" value="ognl:report.name" /></li> > </loop> > > <!-- render recursively child groups --> > <condition jwcid="@Conditional" > condition="ognl:group.reportGroups.size() > 0"> > <loop jwcid="@Foreach" source="ognl:group.reportGroups" > value="ognl:group" > > <span jwcid="@RenderBlock" block="ognl:components.groupBlock"/> > </loop> > </condition> > > </block> > > > *<JWCID>* > <component-specification class="org.apache.tapestry.BaseComponent" > allow-body="no" allow-informal-parameters="no"> > > <parameter name="group" type="YYY" > required="yes" > direction="auto" > /> > > <property-specification name="report" type="XXX"/> > > </component-specification> > > > best regards, > Bernard > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- Dan Adams Senior Software Engineer Interactive Factory 617.235.5857 --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]