You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "Byrne, Steven" <SB...@dorado.com> on 2004/01/22 07:50:04 UTC

Listener access in deeply nested components?

I love Tapestry's component oriented design; it's refreshing after dealing with Struts.

I do have one situation where I'm not sure what the correct "Tapestry" way to do things is, and I was hoping the collected wisdom of the list can help me out.

Basically I have a component that contains a form, and within the scope of that form is another component which contains a further component.  In ASCII-grams:

....Component A  (<form jwcid="@Form"...>)
........Component B
............Component C (wants to invoke a listener "someListener")

Component C wants to invoke a listener via a LinkSubmit that's defined in the Java class that's a part of Component A. 

The question is: what's the right way to allow component C to access this listener?  If Component A were the top level page, I could say 

    <...LinkSubmit...listener="ognl:page.listeners.someListener">

But this feels clumsy.  I can arrange for Component A to explicitly pass the listener as a parameter in to Component B, which then explictly passes it to Component C via a parameter defined in the component-specification.  Again, this feels a little clumsy, but it works.

Is there a better way to do this?  Is there some "global set of listeners" that I can access via some OGNL expression?  Can I just have an inherited binding in Component B (and maybe C too, or maybe just C?) for the listener and not have to explicitly pass the parameter via the HTML templates for components A and B?

Steve


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


Re: Listener access in deeply nested components?

Posted by Geoff Longman <gl...@intelligentworks.com>.
just pass the listener around as a parameter



----- Original Message -----
From: "Harish Krishnaswamy" <hk...@comcast.net>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Thursday, January 22, 2004 9:27 AM
Subject: Re: Listener access in deeply nested components?


> If it is the behavior of ComponentC then the listener actually belongs
> in ComponentCClass, I think. Or if Component A, B and C are related then
> you might consider wrapping these components into another component and
> then you can say container.listeners.whatever.
>
> I don't think its a good idea to invoke a listener in a container at an
> arbitrary level in the hierarchy. That defies the black-box concept, I
> think.
>
> -Harish
>
> Byrne, Steven wrote:
>
> >I love Tapestry's component oriented design; it's refreshing after
dealing with Struts.
> >
> >I do have one situation where I'm not sure what the correct "Tapestry"
way to do things is, and I was hoping the collected wisdom of the list can
help me out.
> >
> >Basically I have a component that contains a form, and within the scope
of that form is another component which contains a further component.  In
ASCII-grams:
> >
> >....Component A  (<form jwcid="@Form"...>)
> >........Component B
> >............Component C (wants to invoke a listener "someListener")
> >
> >Component C wants to invoke a listener via a LinkSubmit that's defined in
the Java class that's a part of Component A.
> >
> >The question is: what's the right way to allow component C to access this
listener?  If Component A were the top level page, I could say
> >
> >    <...LinkSubmit...listener="ognl:page.listeners.someListener">
> >
> >But this feels clumsy.  I can arrange for Component A to explicitly pass
the listener as a parameter in to Component B, which then explictly passes
it to Component C via a parameter defined in the component-specification.
Again, this feels a little clumsy, but it works.
> >
> >Is there a better way to do this?  Is there some "global set of
listeners" that I can access via some OGNL expression?  Can I just have an
inherited binding in Component B (and maybe C too, or maybe just C?) for the
listener and not have to explicitly pass the parameter via the HTML
templates for components A and B?
> >
> >Steve
> >
> >
> >---------------------------------------------------------------------
> >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
>


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


Re: Listener access in deeply nested components?

Posted by Harish Krishnaswamy <hk...@comcast.net>.
If it is the behavior of ComponentC then the listener actually belongs 
in ComponentCClass, I think. Or if Component A, B and C are related then 
you might consider wrapping these components into another component and 
then you can say container.listeners.whatever.

I don't think its a good idea to invoke a listener in a container at an 
arbitrary level in the hierarchy. That defies the black-box concept, I 
think.

-Harish

Byrne, Steven wrote:

>I love Tapestry's component oriented design; it's refreshing after dealing with Struts.
>
>I do have one situation where I'm not sure what the correct "Tapestry" way to do things is, and I was hoping the collected wisdom of the list can help me out.
>
>Basically I have a component that contains a form, and within the scope of that form is another component which contains a further component.  In ASCII-grams:
>
>....Component A  (<form jwcid="@Form"...>)
>........Component B
>............Component C (wants to invoke a listener "someListener")
>
>Component C wants to invoke a listener via a LinkSubmit that's defined in the Java class that's a part of Component A. 
>
>The question is: what's the right way to allow component C to access this listener?  If Component A were the top level page, I could say 
>
>    <...LinkSubmit...listener="ognl:page.listeners.someListener">
>
>But this feels clumsy.  I can arrange for Component A to explicitly pass the listener as a parameter in to Component B, which then explictly passes it to Component C via a parameter defined in the component-specification.  Again, this feels a little clumsy, but it works.
>
>Is there a better way to do this?  Is there some "global set of listeners" that I can access via some OGNL expression?  Can I just have an inherited binding in Component B (and maybe C too, or maybe just C?) for the listener and not have to explicitly pass the parameter via the HTML templates for components A and B?
>
>Steve
>
>
>---------------------------------------------------------------------
>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


RE: Listener access in deeply nested components?

Posted by "Howard M. Lewis Ship" <hl...@comcast.net>.
Parameters are the correct way to do this. Make sure the parameters use direction "auto".

Globals in Tapestry are available, but have the same types of problems you will see using globals in
any Java program. Better to use parameters.

--
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Tapestry: Java Web Components 
http://jakarta.apache.org/tapestry/
http://javatapestry.blogspot.com

> -----Original Message-----
> From: Byrne, Steven [mailto:SByrne@dorado.com] 
> Sent: Thursday, January 22, 2004 1:50 AM
> To: tapestry-user@jakarta.apache.org
> Subject: Listener access in deeply nested components?
> 
> 
> I love Tapestry's component oriented design; it's refreshing 
> after dealing with Struts.
> 
> I do have one situation where I'm not sure what the correct 
> "Tapestry" way to do things is, and I was hoping the 
> collected wisdom of the list can help me out.
> 
> Basically I have a component that contains a form, and within 
> the scope of that form is another component which contains a 
> further component.  In ASCII-grams:
> 
> ....Component A  (<form jwcid="@Form"...>)
> ........Component B
> ............Component C (wants to invoke a listener "someListener")
> 
> Component C wants to invoke a listener via a LinkSubmit 
> that's defined in the Java class that's a part of Component A. 
> 
> The question is: what's the right way to allow component C to 
> access this listener?  If Component A were the top level 
> page, I could say 
> 
>     <...LinkSubmit...listener="ognl:page.listeners.someListener">
> 
> But this feels clumsy.  I can arrange for Component A to 
> explicitly pass the listener as a parameter in to Component 
> B, which then explictly passes it to Component C via a 
> parameter defined in the component-specification.  Again, 
> this feels a little clumsy, but it works.
> 
> Is there a better way to do this?  Is there some "global set 
> of listeners" that I can access via some OGNL expression?  
> Can I just have an inherited binding in Component B (and 
> maybe C too, or maybe just C?) for the listener and not have 
> to explicitly pass the parameter via the HTML templates for 
> components A and B?
> 
> Steve
> 
> 
> ---------------------------------------------------------------------
> 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