You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Taha Hafeez <ta...@gmail.com> on 2011/04/11 15:13:09 UTC
Components communication with nested components
Hi
I have at times come across cases where I have a component which has to
communicate with its nested components. For that I use Environment and push
the context at setupRender(). That works as long as the internal component
does not contain a form. If it contains a form, at the time of submission, I
don't get the environment, that is understood as setupRender() of the main
component is not called. So, what I do is persist the context first time
around and use it later. Is this the correct way, or is there a better way
to do this...
Hope I have explained my question well
regards
Taha
Re: Components communication with nested components
Posted by Taha Hafeez <ta...@gmail.com>.
If i understand correctly, it is possible to use @Environmental in render
phase, as the parent and nested components both go through that
phase but in action phase only the nested component events will be called.
Your second suggestion seems very interesting. It will be very helpful if
you can elaborate on that (especially with a small example).
regards
Taha
On Tue, Apr 12, 2011 at 4:02 PM, Kristian Marinkovic <
kristian.marinkovic@porscheinformatik.at> wrote:
> there are two phases in tapestry: the action phase and the render phase.
> for every phase you have to set your environmental services explicitly.
>
> i often have services that use the ApplicationStateManager service
> directly to access the persisted data, so my components are only aware of
> the service interface. this way i can reload the data whenever i need it
> lazily without coupling the components to my data objects. i hope this
> gives you some ideas.
>
> g,
> kris
>
>
>
> Von: Taha Hafeez <ta...@gmail.com>
> An: Tapestry users <us...@tapestry.apache.org>
> Datum: 12.04.2011 12:24
> Betreff: Re: Components communication with nested components
>
>
>
> I am also using @Environmental but it is not availiable at all times. e.g.
> when the nested component contains a form and that form is submitted... So
> in order to deal with it I use @Persist, first time around and on form
> submission I use the persisted value as the environment does not contain
> the
> context...
>
> What i was asking is, whether what I am doing is the way to go or there is
> any other alternative.
>
> regards
> Taha
>
>
> On Tue, Apr 12, 2011 at 3:47 PM, Kristian Marinkovic <
> kristian.marinkovic@porscheinformatik.at> wrote:
>
> > Declaring all possible values as parameters leads to high coupling. Just
> > imagine declaring the parameters in a hierarchy of 5 components just to
> > have it.
> >
> > I'd use Environmental services to pass data between different component
> > hierarchies. You can also apply the MVC pattern: create a service
> (thread
> > scoped service or SSO) that acts as the model that the components can
> use
> > to pull data from it. the service interface acts as the contract between
> > component and model
> >
> > g,
> > kris
> >
> >
> >
> > Von: Taha Hafeez <ta...@gmail.com>
> > An: Tapestry users <us...@tapestry.apache.org>
> > Datum: 11.04.2011 18:00
> > Betreff: Re: Components communication with nested components
> >
> >
> >
> > But my problem is parent does not have any knowledge of the child. Child
> > is
> > either contained in the body somewhere or in an override block
> >
> > e.g
> >
> > Parent
> >
> > <t:container>
> > <t:body>
> > </t:container>
> >
> > Later in use
> >
> > <t:parent>
> > <t:someChild/>
> > </t:parent>
> >
> > so, parameters is not an option
> >
> > regards
> > Taha
> >
> >
> > On Mon, Apr 11, 2011 at 9:04 PM, Christian Köberl <
> > tapestry.christian.koeberl@gmail.com> wrote:
> >
> > > You could use parameters - Tapestry keeps them always in sync:
> > >
> > > public class Parent
> > > {
> > > // here Parent's state is bound to Child's state
> > > @Component(parameters = "state=state")
> > > private Child child;
> > >
> > > @Property
> > > private String state;
> > > }
> > >
> > > public class Child
> > > {
> > > @Parameter
> > > private String state;
> > > }
> > >
> > > see also http://tapestry.apache.org/component-parameters.html
> > >
> > > --
> > > Chris
> > >
> > > --
> > > View this message in context:
> > >
> >
> >
>
> http://tapestry-users.832.n2.nabble.com/Components-communication-with-nested-components-tp6261431p6261909.html
>
> >
> > > Sent from the Tapestry Users mailing list archive at Nabble.com.
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
> >
> >
>
>
Re: Components communication with nested components
Posted by Kristian Marinkovic <kr...@porscheinformatik.at>.
there are two phases in tapestry: the action phase and the render phase.
for every phase you have to set your environmental services explicitly.
i often have services that use the ApplicationStateManager service
directly to access the persisted data, so my components are only aware of
the service interface. this way i can reload the data whenever i need it
lazily without coupling the components to my data objects. i hope this
gives you some ideas.
g,
kris
Von: Taha Hafeez <ta...@gmail.com>
An: Tapestry users <us...@tapestry.apache.org>
Datum: 12.04.2011 12:24
Betreff: Re: Components communication with nested components
I am also using @Environmental but it is not availiable at all times. e.g.
when the nested component contains a form and that form is submitted... So
in order to deal with it I use @Persist, first time around and on form
submission I use the persisted value as the environment does not contain
the
context...
What i was asking is, whether what I am doing is the way to go or there is
any other alternative.
regards
Taha
On Tue, Apr 12, 2011 at 3:47 PM, Kristian Marinkovic <
kristian.marinkovic@porscheinformatik.at> wrote:
> Declaring all possible values as parameters leads to high coupling. Just
> imagine declaring the parameters in a hierarchy of 5 components just to
> have it.
>
> I'd use Environmental services to pass data between different component
> hierarchies. You can also apply the MVC pattern: create a service
(thread
> scoped service or SSO) that acts as the model that the components can
use
> to pull data from it. the service interface acts as the contract between
> component and model
>
> g,
> kris
>
>
>
> Von: Taha Hafeez <ta...@gmail.com>
> An: Tapestry users <us...@tapestry.apache.org>
> Datum: 11.04.2011 18:00
> Betreff: Re: Components communication with nested components
>
>
>
> But my problem is parent does not have any knowledge of the child. Child
> is
> either contained in the body somewhere or in an override block
>
> e.g
>
> Parent
>
> <t:container>
> <t:body>
> </t:container>
>
> Later in use
>
> <t:parent>
> <t:someChild/>
> </t:parent>
>
> so, parameters is not an option
>
> regards
> Taha
>
>
> On Mon, Apr 11, 2011 at 9:04 PM, Christian Köberl <
> tapestry.christian.koeberl@gmail.com> wrote:
>
> > You could use parameters - Tapestry keeps them always in sync:
> >
> > public class Parent
> > {
> > // here Parent's state is bound to Child's state
> > @Component(parameters = "state=state")
> > private Child child;
> >
> > @Property
> > private String state;
> > }
> >
> > public class Child
> > {
> > @Parameter
> > private String state;
> > }
> >
> > see also http://tapestry.apache.org/component-parameters.html
> >
> > --
> > Chris
> >
> > --
> > View this message in context:
> >
>
>
http://tapestry-users.832.n2.nabble.com/Components-communication-with-nested-components-tp6261431p6261909.html
>
> > Sent from the Tapestry Users mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
Re: Components communication with nested components
Posted by Taha Hafeez <ta...@gmail.com>.
I am also using @Environmental but it is not availiable at all times. e.g.
when the nested component contains a form and that form is submitted... So
in order to deal with it I use @Persist, first time around and on form
submission I use the persisted value as the environment does not contain the
context...
What i was asking is, whether what I am doing is the way to go or there is
any other alternative.
regards
Taha
On Tue, Apr 12, 2011 at 3:47 PM, Kristian Marinkovic <
kristian.marinkovic@porscheinformatik.at> wrote:
> Declaring all possible values as parameters leads to high coupling. Just
> imagine declaring the parameters in a hierarchy of 5 components just to
> have it.
>
> I'd use Environmental services to pass data between different component
> hierarchies. You can also apply the MVC pattern: create a service (thread
> scoped service or SSO) that acts as the model that the components can use
> to pull data from it. the service interface acts as the contract between
> component and model
>
> g,
> kris
>
>
>
> Von: Taha Hafeez <ta...@gmail.com>
> An: Tapestry users <us...@tapestry.apache.org>
> Datum: 11.04.2011 18:00
> Betreff: Re: Components communication with nested components
>
>
>
> But my problem is parent does not have any knowledge of the child. Child
> is
> either contained in the body somewhere or in an override block
>
> e.g
>
> Parent
>
> <t:container>
> <t:body>
> </t:container>
>
> Later in use
>
> <t:parent>
> <t:someChild/>
> </t:parent>
>
> so, parameters is not an option
>
> regards
> Taha
>
>
> On Mon, Apr 11, 2011 at 9:04 PM, Christian Köberl <
> tapestry.christian.koeberl@gmail.com> wrote:
>
> > You could use parameters - Tapestry keeps them always in sync:
> >
> > public class Parent
> > {
> > // here Parent's state is bound to Child's state
> > @Component(parameters = "state=state")
> > private Child child;
> >
> > @Property
> > private String state;
> > }
> >
> > public class Child
> > {
> > @Parameter
> > private String state;
> > }
> >
> > see also http://tapestry.apache.org/component-parameters.html
> >
> > --
> > Chris
> >
> > --
> > View this message in context:
> >
>
> http://tapestry-users.832.n2.nabble.com/Components-communication-with-nested-components-tp6261431p6261909.html
>
> > Sent from the Tapestry Users mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
Re: Components communication with nested components
Posted by Kristian Marinkovic <kr...@porscheinformatik.at>.
Declaring all possible values as parameters leads to high coupling. Just
imagine declaring the parameters in a hierarchy of 5 components just to
have it.
I'd use Environmental services to pass data between different component
hierarchies. You can also apply the MVC pattern: create a service (thread
scoped service or SSO) that acts as the model that the components can use
to pull data from it. the service interface acts as the contract between
component and model
g,
kris
Von: Taha Hafeez <ta...@gmail.com>
An: Tapestry users <us...@tapestry.apache.org>
Datum: 11.04.2011 18:00
Betreff: Re: Components communication with nested components
But my problem is parent does not have any knowledge of the child. Child
is
either contained in the body somewhere or in an override block
e.g
Parent
<t:container>
<t:body>
</t:container>
Later in use
<t:parent>
<t:someChild/>
</t:parent>
so, parameters is not an option
regards
Taha
On Mon, Apr 11, 2011 at 9:04 PM, Christian Köberl <
tapestry.christian.koeberl@gmail.com> wrote:
> You could use parameters - Tapestry keeps them always in sync:
>
> public class Parent
> {
> // here Parent's state is bound to Child's state
> @Component(parameters = "state=state")
> private Child child;
>
> @Property
> private String state;
> }
>
> public class Child
> {
> @Parameter
> private String state;
> }
>
> see also http://tapestry.apache.org/component-parameters.html
>
> --
> Chris
>
> --
> View this message in context:
>
http://tapestry-users.832.n2.nabble.com/Components-communication-with-nested-components-tp6261431p6261909.html
> Sent from the Tapestry Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
Re: Components communication with nested components
Posted by Taha Hafeez <ta...@gmail.com>.
But my problem is parent does not have any knowledge of the child. Child is
either contained in the body somewhere or in an override block
e.g
Parent
<t:container>
<t:body>
</t:container>
Later in use
<t:parent>
<t:someChild/>
</t:parent>
so, parameters is not an option
regards
Taha
On Mon, Apr 11, 2011 at 9:04 PM, Christian Köberl <
tapestry.christian.koeberl@gmail.com> wrote:
> You could use parameters - Tapestry keeps them always in sync:
>
> public class Parent
> {
> // here Parent's state is bound to Child's state
> @Component(parameters = "state=state")
> private Child child;
>
> @Property
> private String state;
> }
>
> public class Child
> {
> @Parameter
> private String state;
> }
>
> see also http://tapestry.apache.org/component-parameters.html
>
> --
> Chris
>
> --
> View this message in context:
> http://tapestry-users.832.n2.nabble.com/Components-communication-with-nested-components-tp6261431p6261909.html
> Sent from the Tapestry Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
Re: Components communication with nested components
Posted by Christian Köberl <ta...@gmail.com>.
You could use parameters - Tapestry keeps them always in sync:
public class Parent
{
// here Parent's state is bound to Child's state
@Component(parameters = "state=state")
private Child child;
@Property
private String state;
}
public class Child
{
@Parameter
private String state;
}
see also http://tapestry.apache.org/component-parameters.html
--
Chris
--
View this message in context: http://tapestry-users.832.n2.nabble.com/Components-communication-with-nested-components-tp6261431p6261909.html
Sent from the Tapestry Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org