Delay component rendering

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Delay component rendering

sg-4
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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Delay component rendering

richard.hensley
Review Howard's blog at http://howardlewisship.com/blog

He wrote a component that did some defering of rendering. I'm not sure it's
the same exact use case, but it might be a good start.

By the way, this problem can also be solved using CSS positioning.

Richard

-----Original Message-----
From: [hidden email] [mailto:[hidden email]]
Sent: Tuesday, May 17, 2005 7:14 AM
To: Tapestry User; [hidden email]
Subject: 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: [hidden email]
For additional commands, e-mail: [hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Delay component rendering

Howard Lewis Ship
In reply to this post by sg-4
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 <[hidden email]> 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: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


--
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
Reply | Threaded
Open this post in threaded view
|

Re: Delay component rendering

pferraro
In reply to this post by sg-4
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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Delay component rendering

sg-4
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 <[hidden email]> 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: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


--
-SG

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]