You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by SG <sg...@gmail.com> on 2005/05/17 16:14:20 UTC

Delay component rendering

Hi,

I wanted to know if there is a way to delay/postpone the rendering of
a particular component programmatically. Here is the scenario -

I have an error component, which works off of a collection of messages
that is stored in the containing page. As components on the page
render, they populate the page message collection with various
messages by type (info, error, warning, etc.). The error component
applies the relevant stylesheets for each message type and displays
them on the screen.

The key thing to note is that the error component is located at the
top of the page before the other components. As such, Tapestry renders
the error component first, then the other components. So, any messages
from the follow-up components are populated in the messages
collection, but not rendered on the screen. The next time the form
submits, those messages render, but they are stale messages from the
previous request.

Question: Is there a way to delay the rendering of a component until
the end of the page render? In this case, I want the error component
to undergo its render process at the end of the page render, after all
the other components are rendered. But, I still want it to show it at
the top of the page before other components.

If I move the error component as the last component on the page,
everything works fine, but the messages show at the bottom of the
page.

Thanks in advance,
-- 
-SG

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


Re: Delay component rendering

Posted by SG <sg...@gmail.com>.
Thanks for your responses. I used what Howard mentioned in his
response and it worked like a charm. I agree that this is another
powerful use of Blocks, but I am a bit wary of the amount of Tapestry
internals that a developer has to know to get simple things like this
done. We have used Tapestry for a rich web app, and I can definitely
see an advantage that we have gained because of that. But simple
things like this take considerable amount of time. But, then, this
user forum is a great resource for these kinds of things.

Thanks again.
-SG

On 5/17/05, Paul Ferraro <pm...@columbia.edu> wrote:
> Look at the code for the Form and Body components.  They both have this
> behavior.
> 
> Paul
> 
> SG wrote:
> 
> >Hi,
> >
> >I wanted to know if there is a way to delay/postpone the rendering of
> >a particular component programmatically. Here is the scenario -
> >
> >I have an error component, which works off of a collection of messages
> >that is stored in the containing page. As components on the page
> >render, they populate the page message collection with various
> >messages by type (info, error, warning, etc.). The error component
> >applies the relevant stylesheets for each message type and displays
> >them on the screen.
> >
> >The key thing to note is that the error component is located at the
> >top of the page before the other components. As such, Tapestry renders
> >the error component first, then the other components. So, any messages
> >from the follow-up components are populated in the messages
> >collection, but not rendered on the screen. The next time the form
> >submits, those messages render, but they are stale messages from the
> >previous request.
> >
> >Question: Is there a way to delay the rendering of a component until
> >the end of the page render? In this case, I want the error component
> >to undergo its render process at the end of the page render, after all
> >the other components are rendered. But, I still want it to show it at
> >the top of the page before other components.
> >
> >If I move the error component as the last component on the page,
> >everything works fine, but the messages show at the bottom of the
> >page.
> >
> >Thanks in advance,
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


-- 
-SG

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


Re: Delay component rendering

Posted by Paul Ferraro <pm...@columbia.edu>.
Look at the code for the Form and Body components.  They both have this 
behavior.

Paul

SG wrote:

>Hi,
>
>I wanted to know if there is a way to delay/postpone the rendering of
>a particular component programmatically. Here is the scenario -
>
>I have an error component, which works off of a collection of messages
>that is stored in the containing page. As components on the page
>render, they populate the page message collection with various
>messages by type (info, error, warning, etc.). The error component
>applies the relevant stylesheets for each message type and displays
>them on the screen.
>
>The key thing to note is that the error component is located at the
>top of the page before the other components. As such, Tapestry renders
>the error component first, then the other components. So, any messages
>from the follow-up components are populated in the messages
>collection, but not rendered on the screen. The next time the form
>submits, those messages render, but they are stale messages from the
>previous request.
>
>Question: Is there a way to delay the rendering of a component until
>the end of the page render? In this case, I want the error component
>to undergo its render process at the end of the page render, after all
>the other components are rendered. But, I still want it to show it at
>the top of the page before other components.
>
>If I move the error component as the last component on the page,
>everything works fine, but the messages show at the bottom of the
>page.
>
>Thanks in advance,
>  
>


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


Re: Delay component rendering

Posted by Howard Lewis Ship <hl...@gmail.com>.
Many components do this, pseudo code follows:

protected void renderComponent(...)
{
IMarkupWriter nested = writer.getNestedWriter();

renderBody(nested, cycle);

// Do my rendering here ...

nested.close(); // Output buffered content
}

On 5/17/05, SG <sg...@gmail.com> wrote:
> 
> Hi,
> 
> I wanted to know if there is a way to delay/postpone the rendering of
> a particular component programmatically. Here is the scenario -
> 
> I have an error component, which works off of a collection of messages
> that is stored in the containing page. As components on the page
> render, they populate the page message collection with various
> messages by type (info, error, warning, etc.). The error component
> applies the relevant stylesheets for each message type and displays
> them on the screen.
> 
> The key thing to note is that the error component is located at the
> top of the page before the other components. As such, Tapestry renders
> the error component first, then the other components. So, any messages
> from the follow-up components are populated in the messages
> collection, but not rendered on the screen. The next time the form
> submits, those messages render, but they are stale messages from the
> previous request.
> 
> Question: Is there a way to delay the rendering of a component until
> the end of the page render? In this case, I want the error component
> to undergo its render process at the end of the page render, after all
> the other components are rendered. But, I still want it to show it at
> the top of the page before other components.
> 
> If I move the error component as the last component on the page,
> everything works fine, but the messages show at the bottom of the
> page.
> 
> Thanks in advance,
> --
> -SG
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


-- 
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Jakarta Tapestry
Creator, Jakarta HiveMind

Professional Tapestry training, mentoring, support
and project work. http://howardlewisship.com