You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Paul Stanton <pa...@mapshed.com.au> on 2010/06/08 13:57:03 UTC
event handlers - handling by the container (page)
"Note that events that are not handled by a component will bubble up to
the component's container"
I'm a little confused because I thought this meant I could have a
component containing components and handle the events from the root
container aka the page ?
eg
MyLayout.tml
...
<t:form t:id="myForm">
<t:body />
<t:submit t:id="mySubmit" />
</t:form>
...
MyPage.tml
<html t:type="mylayout" ...>
<p>some content</p>
</html>
MyPage.java
...
Object onSuccessFromMyForm()
{
LOG.debug("onSuccessFromMyForm");
}
...
Should this listener get called or should I get :
Request event 'success' (on component MyPage:myForm.success) was not
handled; you must provide a matching event handler method in the
component or in one of its containers.
?
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: event handlers - handling by the container (page)
Posted by Benny Law <be...@gmail.com>.
Try giving your MyLayout component an id in MyPage.tml and use that id in
the event handler name. You can't reference the id of the form component
because it's not a direct child of the page. When an event bubbles up, it
will appear to be coming from the immediate child. I think you can even omit
the id and just have Object onSuccess(), provided there isn't any other form
on the page.
Benny
On Tue, Jun 8, 2010 at 7:57 AM, Paul Stanton <pa...@mapshed.com.au> wrote:
> "Note that events that are not handled by a component will bubble up to the
> component's container"
>
> I'm a little confused because I thought this meant I could have a component
> containing components and handle the events from the root container aka the
> page ?
>
> eg
>
> MyLayout.tml
> ...
> <t:form t:id="myForm">
> <t:body />
> <t:submit t:id="mySubmit" />
> </t:form>
> ...
>
> MyPage.tml
> <html t:type="mylayout" ...>
> <p>some content</p>
> </html>
>
> MyPage.java
> ...
> Object onSuccessFromMyForm()
> {
> LOG.debug("onSuccessFromMyForm");
> }
> ...
>
> Should this listener get called or should I get :
> Request event 'success' (on component MyPage:myForm.success) was not
> handled; you must provide a matching event handler method in the component
> or in one of its containers.
>
> ?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
Re: event handlers - handling by the container (page)
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, 08 Jun 2010 09:40:52 -0300, Paul Stanton <pa...@mapshed.com.au>
wrote:
> Sorry Thiago, Thanks for the answer but I'm still not sure i've
> explained this properly. Take the following example...
>
> I have a page 'MyPage', who's root element is <html t:type="mylayout"
> ...>.
>
> Within MyLayout i have an actionlink 'MyLink'.
>
> I want to handle the event 'onActionFromMyLink' in MyPage.java. I would
> expect that from innermost to outermost the component tree would be
> MyLink-MyLayout-MyPage and therefore MyPage would be the root container
> therefore could ultimately handle the event.
Instead of using an ActionLink and rely on its t:id, use an EventLink and
rely on the event name. You shouldn't rely on component id when the
component isn't directly inside your component or page.
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: event handlers - handling by the container (page)
Posted by Paul Stanton <pa...@mapshed.com.au>.
Sorry Thiago, Thanks for the answer but I'm still not sure i've
explained this properly. Take the following example...
I have a page 'MyPage', who's root element is <html t:type="mylayout" ...>.
Within MyLayout i have an actionlink 'MyLink'.
I want to handle the event 'onActionFromMyLink' in MyPage.java. I would
expect that from innermost to outermost the component tree would be
MyLink-MyLayout-MyPage and therefore MyPage would be the root container
therefore could ultimately handle the event.
However when i try this I get the error. What have I misunderstood?
Regards, Paul.
Thiago H. de Paula Figueiredo wrote:
> On Tue, 08 Jun 2010 08:57:03 -0300, Paul Stanton <pa...@mapshed.com.au>
> wrote:
>
>> "Note that events that are not handled by a component will bubble up
>> to the component's container"
>>
>> I'm a little confused because I thought this meant I could have a
>> component containing components and handle the events from the root
>> container aka the page ?
>
> The reverse is true. Think of the page and its components as a tree.
> The page is the root, so it's on top. Events bubble up: from innermost
> to outermost.
>
>> Should this listener get called or should I get :
>> Request event 'success' (on component MyPage:myForm.success) was not
>> handled; you must provide a matching event handler method in the
>> component or in one of its containers.
>
> Testing yourself would give you a faster answer and it's a wonderful
> way to learn how Tapestry works.. :)
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: event handlers - handling by the container (page)
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, 08 Jun 2010 08:57:03 -0300, Paul Stanton <pa...@mapshed.com.au>
wrote:
> "Note that events that are not handled by a component will bubble up to
> the component's container"
>
> I'm a little confused because I thought this meant I could have a
> component containing components and handle the events from the root
> container aka the page ?
The reverse is true. Think of the page and its components as a tree. The
page is the root, so it's on top. Events bubble up: from innermost to
outermost.
> Should this listener get called or should I get :
> Request event 'success' (on component MyPage:myForm.success) was not
> handled; you must provide a matching event handler method in the
> component or in one of its containers.
Testing yourself would give you a faster answer and it's a wonderful way
to learn how Tapestry works.. :)
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org