You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by HBKTron <ma...@gmail.com> on 2008/01/24 21:03:45 UTC
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="myFavoriteDiv">Big 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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Problem using EventListener annotation
Posted by HBKTron <ma...@gmail.com>.
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 <ma...@gmail.com>:
>>
>>
>> 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="myFavoriteDiv">Big 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: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
>
> --
> 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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Problem using EventListener annotation
Posted by Marcus Schulte <et...@googlemail.com>.
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 <ma...@gmail.com>:
>
>
> 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="myFavoriteDiv">Big 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: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
--
Marcus Schulte
http://marcus-schulte.blogspot.com