You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Davor Miku <da...@gmail.com> on 2009/03/03 06:05:44 UTC

Action Link In Parent Component

Hi!

I want to set action link in child component, but action needs to be handled
in parent component.

I tried to hack like:

<t.parent >
     <t.child />
</t.parent>


Class Parent {

 onActionFromChildEvent(int id){
 // Do something ....
    }

}
In child.tml :
<a href="parent.childevent/${something.id}" >Action</a>


but I'm getting :

Component parent does not contain an embedded component with id
'childevent'.

How can I achieve this?

Re: Action Link In Parent Component

Posted by Robert Zeigler <ro...@scazdl.org>.
Nah, that's not true, sorry. Event bubbling happens regardless of the  
method visibility.

The issue here is understanding how event bubbling works.

When the child component contains an action link, it may do one of  
three things:
1) It may handle the action (onAction) and prevent bubbling
2) It may ignore the action, and bubbling will occur
3) It may handle the action and generate its own custom event.

What you want, DH, is either 2 or 3.  I like #3 a lot because it makes  
the parent component agnostic to the way the event is generated in the  
child.
In the case of #2, which is what you were trying to do, the event is  
propagated as though it originated from the child component.

So, instead of:

onActionFromChildEvent, you need:

onActionFromChild

Or event:
@OnEvent(value="action",component="child")
void foo() {
}

Cheers,

Robert

On Mar 3, 2009, at 3/34:26 AM , Inge Solvoll wrote:

> Make sure that the parent listener has the correct visibility. If the
> listener is package private and the child component is in a different
> package, the listener won't be triggered...
>
> On Tue, Mar 3, 2009 at 10:21 AM, dhning <ni...@gmail.com> wrote:
>
>> I think what you need is
>> Class Parent {
>> onChildEvent(int id){
>> // Do something ....
>> }
>>
>>
>> Thanks,
>>
>> DH
>>
>>
>> ----- Original Message -----
>> From: "Davor Miku" <da...@gmail.com>
>> To: "Tapestry users" <us...@tapestry.apache.org>
>> Sent: Tuesday, March 03, 2009 1:05 PM
>> Subject: Action Link In Parent Component
>>
>>
>>> Hi!
>>>
>>> I want to set action link in child component, but action needs to be
>> handled
>>> in parent component.
>>>
>>> I tried to hack like:
>>>
>>> <t.parent >
>>>    <t.child />
>>> </t.parent>
>>>
>>>
>>> Class Parent {
>>>
>>> onActionFromChildEvent(int id){
>>> // Do something ....
>>>   }
>>>
>>> }
>>> In child.tml :
>>> <a href="parent.childevent/${something.id}" >Action</a>
>>>
>>>
>>> but I'm getting :
>>>
>>> Component parent does not contain an embedded component with id
>>> 'childevent'.
>>>
>>> How can I achieve this?
>>>
>>


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


Re: Action Link In Parent Component

Posted by Andy Pahne <an...@googlemail.com>.

Or is Eventink what you are searching for?

see 
http://tapestry.formos.com/nightly/tapestry5/tapestry-core/ref/org/apache/tapestry5/corelib/components/EventLink.html


Inge Solvoll wrote:
> Make sure that the parent listener has the correct visibility. If the
> listener is package private and the child component is in a different
> package, the listener won't be triggered...
>
> On Tue, Mar 3, 2009 at 10:21 AM, dhning<ni...@gmail.com>  wrote:
>
>    
>> I think what you need is
>> Class Parent {
>>   onChildEvent(int id){
>> // Do something ....
>> }
>>
>>
>> Thanks,
>>
>> DH
>>
>>
>> ----- Original Message -----
>> From: "Davor Miku"<da...@gmail.com>
>> To: "Tapestry users"<us...@tapestry.apache.org>
>> Sent: Tuesday, March 03, 2009 1:05 PM
>> Subject: Action Link In Parent Component
>>
>>
>>      
>>> Hi!
>>>
>>> I want to set action link in child component, but action needs to be
>>>        
>> handled
>>      
>>> in parent component.
>>>
>>> I tried to hack like:
>>>
>>> <t.parent>
>>>      <t.child />
>>> </t.parent>
>>>
>>>
>>> Class Parent {
>>>
>>> onActionFromChildEvent(int id){
>>> // Do something ....
>>>     }
>>>
>>> }
>>> In child.tml :
>>> <a href="parent.childevent/${something.id}">Action</a>
>>>
>>>
>>> but I'm getting :
>>>
>>> Component parent does not contain an embedded component with id
>>> 'childevent'.
>>>
>>> How can I achieve this?
>>>
>>>        
>
>    


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


Re: Action Link In Parent Component

Posted by Inge Solvoll <in...@gmail.com>.
Make sure that the parent listener has the correct visibility. If the
listener is package private and the child component is in a different
package, the listener won't be triggered...

On Tue, Mar 3, 2009 at 10:21 AM, dhning <ni...@gmail.com> wrote:

> I think what you need is
> Class Parent {
>  onChildEvent(int id){
> // Do something ....
> }
>
>
> Thanks,
>
> DH
>
>
> ----- Original Message -----
> From: "Davor Miku" <da...@gmail.com>
> To: "Tapestry users" <us...@tapestry.apache.org>
> Sent: Tuesday, March 03, 2009 1:05 PM
> Subject: Action Link In Parent Component
>
>
> > Hi!
> >
> > I want to set action link in child component, but action needs to be
> handled
> > in parent component.
> >
> > I tried to hack like:
> >
> > <t.parent >
> >     <t.child />
> > </t.parent>
> >
> >
> > Class Parent {
> >
> > onActionFromChildEvent(int id){
> > // Do something ....
> >    }
> >
> > }
> > In child.tml :
> > <a href="parent.childevent/${something.id}" >Action</a>
> >
> >
> > but I'm getting :
> >
> > Component parent does not contain an embedded component with id
> > 'childevent'.
> >
> > How can I achieve this?
> >
>

Re: Action Link In Parent Component

Posted by dhning <ni...@gmail.com>.
I think what you need is
Class Parent {
 onChildEvent(int id){
// Do something ....
}


Thanks,

DH


----- Original Message ----- 
From: "Davor Miku" <da...@gmail.com>
To: "Tapestry users" <us...@tapestry.apache.org>
Sent: Tuesday, March 03, 2009 1:05 PM
Subject: Action Link In Parent Component


> Hi!
> 
> I want to set action link in child component, but action needs to be handled
> in parent component.
> 
> I tried to hack like:
> 
> <t.parent >
>     <t.child />
> </t.parent>
> 
> 
> Class Parent {
> 
> onActionFromChildEvent(int id){
> // Do something ....
>    }
> 
> }
> In child.tml :
> <a href="parent.childevent/${something.id}" >Action</a>
> 
> 
> but I'm getting :
> 
> Component parent does not contain an embedded component with id
> 'childevent'.
> 
> How can I achieve this?
>