Problem using EventListener annotation
Hi, I'm currently using Tapestry 4.1.3 and I'm trying to copy the EventListener annotation example from: http://tapestry.apache.org/tapestry4.1/ajax/eventlistener.html. The example shows how a method can be annotated with EventListener to respond to DOM events. Unfortunately the EventListener method is never being called when I try to run it. Everything compiles ok, and I've been able to use other Tapestry functionality (such as submit button listeners) on this page. Below is my code, can anyone help me out? Home.html ... body div id=myFavoriteDivBig brother is watching you./div /body ... Home.page ?xml version=1.0? !DOCTYPE page-specification PUBLIC -//Apache Software Foundation//Tapestry Specification 4.0//EN http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd; page-specification class=pages.HomePage /page-specification HomePage.java package pages; import org.apache.tapestry.annotations.EventListener; import org.apache.tapestry.event.BrowserEvent; import org.apache.tapestry.html.BasePage; import org.apache.tapestry.record.PropertyChangeObserver; public class HomePage extends BasePage { @Override public String getClientId() { // TODO Auto-generated method stub return null; } @Override public void setClientId(String arg0) { // TODO Auto-generated method stub } public PropertyChangeObserver getPropertyChangeObserver() { // TODO Auto-generated method stub return null; } @EventListener(elements = myFavoriteDiv, events = onmouseover) public void watchText(BrowserEvent e) { System.out.println(mouseover detected); System.out.println(e); } } -- View this message in context: http://www.nabble.com/Problem-using-EventListener-annotation-tp15072602p15072602.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem using EventListener annotation
1. Make sure, your template includes a @Shell and a @Body component as shown here: http://tapestry.apache.org/tapestry4.1/ajax/basics.html 2. please also try to keep your page-class abstract and remove the auto-generated stubs of methods. Tapestry generates a concrete class for each component/page at runtime (should not be the cause of your trouble, though). 2008/1/24, HBKTron [EMAIL PROTECTED]: Hi, I'm currently using Tapestry 4.1.3 and I'm trying to copy the EventListener annotation example from: http://tapestry.apache.org/tapestry4.1/ajax/eventlistener.html. The example shows how a method can be annotated with EventListener to respond to DOM events. Unfortunately the EventListener method is never being called when I try to run it. Everything compiles ok, and I've been able to use other Tapestry functionality (such as submit button listeners) on this page. Below is my code, can anyone help me out? Home.html ... body div id=myFavoriteDivBig brother is watching you./div /body ... Home.page ?xml version=1.0? !DOCTYPE page-specification PUBLIC -//Apache Software Foundation//Tapestry Specification 4.0//EN http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd; page-specification class=pages.HomePage /page-specification HomePage.java package pages; import org.apache.tapestry.annotations.EventListener; import org.apache.tapestry.event.BrowserEvent; import org.apache.tapestry.html.BasePage; import org.apache.tapestry.record.PropertyChangeObserver; public class HomePage extends BasePage { @Override public String getClientId() { // TODO Auto-generated method stub return null; } @Override public void setClientId(String arg0) { // TODO Auto-generated method stub } public PropertyChangeObserver getPropertyChangeObserver() { // TODO Auto-generated method stub return null; } @EventListener(elements = myFavoriteDiv, events = onmouseover) public void watchText(BrowserEvent e) { System.out.println(mouseover detected); System.out.println(e); } } -- View this message in context: http://www.nabble.com/Problem-using-EventListener-annotation-tp15072602p15072602.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Marcus Schulte http://marcus-schulte.blogspot.com
Re: Problem using EventListener annotation
Thank for the help. Adding @Shell and @Body components resolved the problem. Marcus Schulte wrote: 1. Make sure, your template includes a @Shell and a @Body component as shown here: http://tapestry.apache.org/tapestry4.1/ajax/basics.html 2. please also try to keep your page-class abstract and remove the auto-generated stubs of methods. Tapestry generates a concrete class for each component/page at runtime (should not be the cause of your trouble, though). 2008/1/24, HBKTron [EMAIL PROTECTED]: Hi, I'm currently using Tapestry 4.1.3 and I'm trying to copy the EventListener annotation example from: http://tapestry.apache.org/tapestry4.1/ajax/eventlistener.html. The example shows how a method can be annotated with EventListener to respond to DOM events. Unfortunately the EventListener method is never being called when I try to run it. Everything compiles ok, and I've been able to use other Tapestry functionality (such as submit button listeners) on this page. Below is my code, can anyone help me out? Home.html ... body div id=myFavoriteDivBig brother is watching you./div /body ... Home.page ?xml version=1.0? !DOCTYPE page-specification PUBLIC -//Apache Software Foundation//Tapestry Specification 4.0//EN http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd; page-specification class=pages.HomePage /page-specification HomePage.java package pages; import org.apache.tapestry.annotations.EventListener; import org.apache.tapestry.event.BrowserEvent; import org.apache.tapestry.html.BasePage; import org.apache.tapestry.record.PropertyChangeObserver; public class HomePage extends BasePage { @Override public String getClientId() { // TODO Auto-generated method stub return null; } @Override public void setClientId(String arg0) { // TODO Auto-generated method stub } public PropertyChangeObserver getPropertyChangeObserver() { // TODO Auto-generated method stub return null; } @EventListener(elements = myFavoriteDiv, events = onmouseover) public void watchText(BrowserEvent e) { System.out.println(mouseover detected); System.out.println(e); } } -- View this message in context: http://www.nabble.com/Problem-using-EventListener-annotation-tp15072602p15072602.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Marcus Schulte http://marcus-schulte.blogspot.com -- View this message in context: http://www.nabble.com/Problem-using-EventListener-annotation-tp15072602p15074453.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]