You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "marioosh.net" <ma...@gmail.com> on 2009/12/14 11:34:30 UTC

[newbie] EventListener in Tapestry 5 ?

Is something like that:
http://tapestry.apache.org/tapestry4.1/ajax/EventListener.html
in Tapestry 5 ?

I can't see @EventListener annotation in Tapesty5.

-- 
Pozdrawiam,
Mariusz

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


Re: [newbie] EventListener in Tapestry 5 ?

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Mon, 14 Dec 2009 23:02:41 -0200, Ashwanth Kumar  
<as...@gmail.com> escreveu:

> Well, if you want Mouse and Text field (key press events), use Java  
> Script on the client side, its very useful and efficient. If you're very
> particular, use DWR to map JS events to a Java Class @ server side, but  
> with in-built ajax support, Tapestry doesn't require it though.

I don't see the need for DWR for implementing something that Tapestry  
doesn't implement out-of-the-box. I have one example, but its written in  
Portuguese.

Solution outline:

1) Define an event name.

2) In your page, component or mixin class, @Inject ComponentResources and  
use its createEventLink() to create a link that will trigger that event.

3) Still in the same class, create a method with @OnEvent("yourEventName")  
that handles the event and returns a JSONObject or JSONArray.

4) @Inject RenderSupport and use its addScript() method to generate any  
needed initialization for your JavaScript code, including the event URL.

5) If you use Prototype, use Event.observe('elementId', 'eventName',  
function() { implement your handling here ; }) to listen to the event and  
invoke the event method usint its URL. You'll probably use Ajax.Request.  
transport.responseJSON is exactly the JSONObject or JSONArray you returned  
in your event handler method.

A simple template you can use, based in real code, follows. It reacts to a  
change in a select tag, posts its value, gets the response as a JSON  
object and the changes the value of some <span>s with the object  
properties.

/* This URL is the one created by ComponentResources.createEventLink().
This is the function which is invoked by the JavaScript line added via  
RenderSupport.addScript().
*/
function initialize(url) {

	Event.observe('selectId', 'change', function() {
		
		new Ajax.Request(url, {
			method : 'post',
			parameters: { value: $F('selectId') },
			onSuccess: function(transport) {
				var result = transport.responseJSON;
				$('span1').innerHTML = result.property1;
				$('span2').innerHTML = result.property2;
				$('span3').innerHTML = result.property3;
			}
		});
		
	});
	
}

I hope it helps.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, 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: [newbie] EventListener in Tapestry 5 ?

Posted by Ashwanth Kumar <as...@gmail.com>.
Well, if you want Mouse and Text field (key press events), use Java Script
on the client side, its very useful and efficient. If you're very
particular, use DWR to map JS events to a Java Class @ server side, but with
in-built ajax support, Tapestry doesn't require it though.

Protoype can help u with JS: http://www.prototypejs.org/api/event

<http://www.prototypejs.org/api/event> - Ashwanth Kumar

On Mon, Dec 14, 2009 at 7:25 PM, marioosh.net <ma...@gmail.com>wrote:

>
>
>
> Olle Hallin-2 wrote:
> >
> > I forgot to paste in the JavaDocs link:
> >
> http://tapestry.apache.org/tapestry5.1/apidocs/org/apache/tapestry5/annotations/OnEvent.html
> >
>
> Yes, I know this annotation but...
> i think it doesn't work for events like: mouseover, mouseout, change
> (textfield)...
>
> http://tapestry.apache.org/tapestry5.1/apidocs/org/apache/tapestry5/EventConstants.html
>
>
> --
> View this message in context:
> http://n2.nabble.com/newbie-EventListener-in-Tapestry-5-tp4163378p4164188.html
> Sent from the Tapestry Users 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: [newbie] EventListener in Tapestry 5 ?

Posted by "marioosh.net" <ma...@gmail.com>.


Olle Hallin-2 wrote:
> 
> I forgot to paste in the JavaDocs link:
> http://tapestry.apache.org/tapestry5.1/apidocs/org/apache/tapestry5/annotations/OnEvent.html
> 

Yes, I know this annotation but...
i think it doesn't work for events like: mouseover, mouseout, change
(textfield)...
http://tapestry.apache.org/tapestry5.1/apidocs/org/apache/tapestry5/EventConstants.html


-- 
View this message in context: http://n2.nabble.com/newbie-EventListener-in-Tapestry-5-tp4163378p4164188.html
Sent from the Tapestry Users 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: [newbie] EventListener in Tapestry 5 ?

Posted by Olle Hallin <ol...@hit.se>.
I forgot to paste in the JavaDocs link:

http://tapestry.apache.org/tapestry5.1/apidocs/org/apache/tapestry5/annotations/OnEvent.html

Olle Hallin
Senior Java Developer and Architect
olle.hallin@crisp.se
www.crisp.se
http://www.linkedin.com/in/ollehallin



2009/12/14 Olle Hallin <ol...@hit.se>

> It is.
>
> Add this to your page/component class:
>
>   @OnEvent @Log public void onEvent() {}
>
> and watch the log file for the stream of events that are fired against this
> (catch-all) event handler.
>
> Olle Hallin
> Senior Java Developer and Architect
> olle.hallin@crisp.se
> www.crisp.se
> http://www.linkedin.com/in/ollehallin
>
>
>
> 2009/12/14 marioosh.net <ma...@gmail.com>
>
>
>>
>> Inge Solvoll wrote:
>> >
>> > Check out this one!
>> >
>> >
>> http://chenillekit.codehaus.org/chenillekit-tapestry/ref/org/chenillekit/tapestry/core/mixins/OnEvent.html
>> >
>>
>> Thanks:)
>> But... I see, that is a addition to tapestry. Why is not in native
>> Tapestry
>> 5 ? :(
>>
>> --
>> View this message in context:
>> http://n2.nabble.com/newbie-EventListener-in-Tapestry-5-tp4163378p4163622.html
>> Sent from the Tapestry Users 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: [newbie] EventListener in Tapestry 5 ?

Posted by Olle Hallin <ol...@hit.se>.
It is.

Add this to your page/component class:

  @OnEvent @Log public void onEvent() {}

and watch the log file for the stream of events that are fired against this
(catch-all) event handler.

Olle Hallin
Senior Java Developer and Architect
olle.hallin@crisp.se
www.crisp.se
http://www.linkedin.com/in/ollehallin



2009/12/14 marioosh.net <ma...@gmail.com>

>
>
> Inge Solvoll wrote:
> >
> > Check out this one!
> >
> >
> http://chenillekit.codehaus.org/chenillekit-tapestry/ref/org/chenillekit/tapestry/core/mixins/OnEvent.html
> >
>
> Thanks:)
> But... I see, that is a addition to tapestry. Why is not in native Tapestry
> 5 ? :(
>
> --
> View this message in context:
> http://n2.nabble.com/newbie-EventListener-in-Tapestry-5-tp4163378p4163622.html
> Sent from the Tapestry Users 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: [newbie] EventListener in Tapestry 5 ?

Posted by "marioosh.net" <ma...@gmail.com>.

Inge Solvoll wrote:
> 
> Check out this one!
> 
> http://chenillekit.codehaus.org/chenillekit-tapestry/ref/org/chenillekit/tapestry/core/mixins/OnEvent.html
> 

Thanks:)
But... I see, that is a addition to tapestry. Why is not in native Tapestry
5 ? :( 

-- 
View this message in context: http://n2.nabble.com/newbie-EventListener-in-Tapestry-5-tp4163378p4163622.html
Sent from the Tapestry Users 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: [newbie] EventListener in Tapestry 5 ?

Posted by Inge Solvoll <in...@gmail.com>.
Check out this one!

http://chenillekit.codehaus.org/chenillekit-tapestry/ref/org/chenillekit/tapestry/core/mixins/OnEvent.html

On Mon, Dec 14, 2009 at 11:34 AM, marioosh.net <ma...@gmail.com>wrote:

> Is something like that:
> http://tapestry.apache.org/tapestry4.1/ajax/EventListener.html
> in Tapestry 5 ?
>
> I can't see @EventListener annotation in Tapesty5.
>
> --
> Pozdrawiam,
> Mariusz
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>