You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Vjeran Marcinko <vj...@tis.hr> on 2004/06/11 14:23:53 UTC
ComponentRenderListener needed ?
Hi all.
Has anyone seen a need for something like ComponentRenderListener interface,
thus component could initialize necessary variables in it, that *depend upon
parameters' values*, before rendering?
Pages have PageRenderListener, but as I see it, components can do the same
only by overriding renderComponent() method, and developer should be really
carefull not to forget to call super.renderComponent() at the end.
Let's say I have some component that displays someNumber (getter is
referenced from .html of course). So I would have to do in component class
following:
public int getSomeNumber() {
return someNumber;
}
protected void renderComponent(IMarkupWriter writer, IRequestCycle
cycle) {
someNumber = init(getSomeParameter());
super.renderComponent(writer, cycle);
}
Isn't it a bit ugly ? Or is there some other way ?
-Vjeran
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
RE: ComponentRenderListener needed ?
Posted by "Howard M. Lewis Ship" <hl...@comcast.net>.
Try overriding prepareForRender(), that's its intent. You must invoke the super implementation.
--
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Jakarta Tapestry
Creator, Jakarta HiveMind
http://howardlewisship.com
> -----Original Message-----
> From: Vjeran Marcinko [mailto:vjeran@tis.hr]
> Sent: Friday, June 11, 2004 8:24 AM
> To: tapestry-user@jakarta.apache.org
> Subject: ComponentRenderListener needed ?
>
>
> Hi all.
>
> Has anyone seen a need for something like
> ComponentRenderListener interface,
> thus component could initialize necessary variables in it,
> that *depend upon
> parameters' values*, before rendering?
>
> Pages have PageRenderListener, but as I see it, components
> can do the same
> only by overriding renderComponent() method, and developer
> should be really
> carefull not to forget to call super.renderComponent() at the end.
> Let's say I have some component that displays someNumber (getter is
> referenced from .html of course). So I would have to do in
> component class
> following:
>
> public int getSomeNumber() {
> return someNumber;
> }
>
> protected void renderComponent(IMarkupWriter writer, IRequestCycle
> cycle) {
> someNumber = init(getSomeParameter());
> super.renderComponent(writer, cycle);
> }
>
> Isn't it a bit ugly ? Or is there some other way ?
>
> -Vjeran
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org