Re: event handlers - handling by the container (page)

2010-06-08 Thread Thiago H. de Paula Figueiredo
On Tue, 08 Jun 2010 09:40:52 -0300, Paul Stanton   
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 ...>.


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-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: event handlers - handling by the container (page)

2010-06-08 Thread Benny Law
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  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
> ...
> 
>   
>   
> 
> ...
>
> MyPage.tml
> 
>   some content
> 
>
> 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-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


Re: event handlers - handling by the container (page)

2010-06-08 Thread Paul Stanton
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 .

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  
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-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: event handlers - handling by the container (page)

2010-06-08 Thread Thiago H. de Paula Figueiredo
On Tue, 08 Jun 2010 08:57:03 -0300, Paul Stanton   
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-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



event handlers - handling by the container (page)

2010-06-08 Thread Paul Stanton
"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
...

   
   

...

MyPage.tml

   some content


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-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org