One more thing that Thiago made me aware of is returning the block from
your setupRender method and closing the surrounding element in
afterRender.

Something along the lines of

Object setupRender(MarkupWriter writer) {
  writer.element(...);
  return block;
}

void afterRender(MarkupWriter writer) {
  writer.end();
}

This is obviously much better than fiddling with internal stuff if it
suffices your needs.

I'd recommend to refactor your code to use iteration instead of recursion
if you can. While recursion is very expressive and might save you some
code, Java just isn't a functional language were function calls are cheap.
Additionally you will most likely at some point run into stack space
problems, depending on your data.

Uli

Am Mi, 5.10.2011, 17:53 schrieb Wechsung, Wulf:
> Hello Ulrich,
>
> thanks for the quick response! I would like to use a component template
> but this is one of the few cases where this is afaik impossible due to the
> need for recursion in the rendering.
>
> Thanks for the pointer on how I can proceed!
>
> Kind Regards,
> Wulf
>
>
> -----Original Message-----
> From: Ulrich Stärk [mailto:u...@spielviel.de]
> Sent: Mittwoch, 5. Oktober 2011 15:43
> To: Tapestry users
> Subject: Re: Block parameter
>
> Rendering component markup directly from your component class is only
> useful for very simple
> components. What you want to do is to mimick some of Tapestry's internals
> that are abstracted away
> for a reason. Now would be the time to start using a component template.
>
> (If you really really have to do this which I strongly discourage, you
> would probably need to cast
> the Block to it's implementation, a BlockImpl, instantiate a
> RenderQueueImpl, call BlockImpl's
> render() method to push the child elements to the queue and afterwards
> call the RenderQueueImpl's
> run method. No guarantees though.)
>
> Uli
>
> On 05.10.2011 14:57, Wechsung, Wulf wrote:
>> Hello guys!
>>
>> Is the following at all possible and if so, where in the framework
>> sources might I be able to find an example of how it works?
>>
>> My component has to render html directly ie:
>>
>> beginRender(MarkupWriter mw) {
>>                 mw.element(...)
>>                 etc ...
>> }
>>
>> I now want the component to take a block parameter (ie header) and have
>> this block parameter render within my html ie
>>
>> beginRender( .. ) {
>>                 mw.element("div")
>>                 /** something like:
>> header.render()
>> **/
>>                 mw.end();
>> }
>>
>> For this requirement the block wouldn't even need to do anything
>> dynamic, I just need a way to "inject" specific markup in a general html
>> structure.
>>
>> Thanks for taking the time to read this!
>>
>> Kind Regards,
>> Wulf
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to