You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by livelock <di...@masse.de> on 2006/09/04 00:51:05 UTC

How to implement polling with @EventListener

Hi,
Dojo got a polling mode
(http://archive.dojotoolkit.org/nightly/tests/io/test_ScriptSrcIO.html#CommonArgs).
How do I use that properly with Tapestry 4.1? The EventListener seems not
have anything that ge

I want a component that reads a property from a server all 4 seconds. For
example for stock quotes or even a chat.

Regards,
André
-- 
View this message in context: http://www.nabble.com/How-to-implement-polling-with-%40EventListener-tf2212501.html#a6127728
Sent from the Tapestry - User forum at Nabble.com.


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


Re: How to implement polling with @EventListener

Posted by livelock <di...@masse.de>.
As you have already seen in
http://issues.apache.org/jira/browse/TAPESTRY-1079 it's all due to memory
shortage. Maybe a bug, maybe not, 1MB per request is much, even while
developing.

Jesse: Using the files attached in the above bug report, some exceptions pop
up after leaving the ajax page some minutes untouched, something with
XMLHTTP 404... maybe this now is a bug :-)

Regards


Jessek wrote:
> 
> Ok...I will look into this when I get back from traveling this
> weekend...(flattery will get you everywhere ;) )
> 
> On 9/7/06, livelock <di...@masse.de> wrote:
>>
>>
>> Jesse, thanks for your tremendous efforts! Paying rent is always a good
>> thing
>> (TM).
>>
>> You are right of course. Polling is not the way to go
>> (http://docs.codehaus.org/display/JETTY/Continuations), cometd is. Tomcat
>> will have continuations some day. But we have to start somewhere... at
>> least
>> me :-) I'll add my tapestry pages to JIIRA, they expose some bugs
>> (totally
>> blows with Firefox 2.0), regardless of if polling is the way to go or
>> not.
>> I'll maybe do polling and keep some logic in the client to be able to
>> send
>> deltas.
>>
>> Cheers & always looking forward for you new stuff :-)
>>
>>
>> Jessek wrote:
>> >
>> > There ~will~ be more features like this soon, have been on the tail end
>> of
>> > a
>> > "rent paying" project release and haven't had time for anything else...
>> >
>> > I'm not sure polling is the perfect answer (at least done this way.)
>> You
>> > might check out cometd.org as well. The dojo + jetty guys have been
>> > working
>> > together to make this a lot easier for servlet based apps.
>> >
>> > One of many "to dos" I plan on adding to tapestry at some
>> point..(probably
>> > a
>> > sub project, but will likely happen sooner than later as it seems lots
>> of
>> > people want this)
>> >
>> > On 9/6/06, livelock <di...@masse.de> wrote:
>> >>
>> >>
>> >> Yay, it works, thanks. It really looks like there should be a more
>> >> elegant
>> >> solution to this, but hey, it works.
>> >>
>> >> Now I am facing a different thing, using AJAX requests I only want to
>> >> transfer deltas. For example if there are 11 rows on the screen and on
>> >> the
>> >> next update there is a new one, I don't want to transfer 12 rows then,
>> >> only
>> >> one and add it to the other rows.
>> >> Is there an elegant way? Or do I have to create component instances
>> >> dynamically?
>> >>
>> >> Regards
>> >>
>> >>
>> >> Josh Long wrote:
>> >> >
>> >> > The following is contrived, but works. Mainly, I would create a
>> proper
>> >> > dojo widget and have the event listener bind to that, but this works
>> >> > because of expando properties...
>> >> >
>> >> > In your body of a file called Test.html, I have
>> >> >
>> >> >
>> >> >     <div id ="test"></div>
>> >> >
>> >> >          <script type="text/javascript" >
>> >> >               dojo.require('dojo.lang.*');
>> >> >               dojo.require('dojo.event.*')
>> >> >             var tst =dojo.byId('test');
>> >> >
>> >> >                     tst.update=function()
>> >> >                       {
>> >> >                           dojo.debug ('running')
>> >> >                           dojo.lang.setTimeout( tst.update , 4000) ;
>> >> > // im sure ther animation package had
>> >> > //a proper way of scheduling something for repeating, but...
>> >> >                       };
>> >> >
>> >> >             dojo.addOnLoad(function(){
>> >> >                dojo.byId('test').update() ; // get the ball rolling
>> >> >             });
>> >> >          </script>
>> >> >
>> >> >     <div jwcid="status@Any">
>> >> >               <span jwcid="@Insert" value = "ognl: now">
>> >> >               the current time is
>> >> >               </span>
>> >> >         </div>
>> >> >
>> >> >
>> >> > then in Test.java,
>> >> >
>> >> >
>> >> >     abstract public Date getNow() ;
>> >> >     abstract public void setNow(Date now) ;
>> >> >
>> >> >     @EventListener( elements ="test", async = true ,
>> >> >                     events ="update")
>> >> >     public void update (IRequestCycle cycle )
>> >> >     {
>> >> >         setNow(new Date()) ;
>> >> >         cycle.getResponseBuilder().updateComponent("status");
>> >> >    }
>> >> >
>> >> >
>> >> > and boom!
>> >> >
>> >> > As you load hte page in javascript, test.update gets called which in
>> >> > turn causes the server side event listener to run. The event
>> listener
>> >> > updates the clock (every 4 seconds because I was running this in
>> devel
>> >> > mode and, and I mean nothing, pisses tapestry off more than running
>> in
>> >> > devel mode) and the page reflects it without any refresh.
>> >> >
>> >> > Hope this helps, sort of...
>> >> >
>> >> > Josh
>> >> >
>> >> > On 9/3/06, livelock <di...@masse.de> wrote:
>> >> >>
>> >> >> Hi,
>> >> >> Dojo got a polling mode
>> >> >> (
>> >>
>> http://archive.dojotoolkit.org/nightly/tests/io/test_ScriptSrcIO.html#CommonArgs
>> >> ).
>> >> >> How do I use that properly with Tapestry 4.1? The EventListener
>> seems
>> >> not
>> >> >> have anything that ge
>> >> >>
>> >> >> I want a component that reads a property from a server all 4
>> seconds.
>> >> For
>> >> >> example for stock quotes or even a chat.
>> >> >>
>> >> >> Regards,
>> >> >> André
>> >> >> --
>> >> >> View this message in context:
>> >> >>
>> >>
>> http://www.nabble.com/How-to-implement-polling-with-%40EventListener-tf2212501.html#a6127728
>> >> >> Sent from the Tapestry - User forum at Nabble.com.
>> >> >>
>> >> >>
>> >> >>
>> ---------------------------------------------------------------------
>> >> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> >> >> For additional commands, e-mail: users-help@tapestry.apache.org
>> >> >>
>> >> >>
>> >> >
>> >> >
>> ---------------------------------------------------------------------
>> >> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> >> > For additional commands, e-mail: users-help@tapestry.apache.org
>> >> >
>> >> >
>> >> >
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/How-to-implement-polling-with-%40EventListener-tf2212501.html#a6170249
>> >> Sent from the Tapestry - User forum at Nabble.com.
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> >> For additional commands, e-mail: users-help@tapestry.apache.org
>> >>
>> >>
>> >
>> >
>> > --
>> > Jesse Kuhnert
>> > Tapestry/Dojo/(and a dash of TestNG), team member/developer
>> >
>> > Open source based consulting work centered around
>> > dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/How-to-implement-polling-with-%40EventListener-tf2212501.html#a6188522
>> Sent from the Tapestry - User forum at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> 
> -- 
> Jesse Kuhnert
> Tapestry/Dojo/(and a dash of TestNG), team member/developer
> 
> Open source based consulting work centered around
> dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-implement-polling-with-%40EventListener-tf2212501.html#a6207311
Sent from the Tapestry - User forum at Nabble.com.


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


Re: How to implement polling with @EventListener

Posted by Jesse Kuhnert <jk...@gmail.com>.
Ok...I will look into this when I get back from traveling this
weekend...(flattery will get you everywhere ;) )

On 9/7/06, livelock <di...@masse.de> wrote:
>
>
> Jesse, thanks for your tremendous efforts! Paying rent is always a good
> thing
> (TM).
>
> You are right of course. Polling is not the way to go
> (http://docs.codehaus.org/display/JETTY/Continuations), cometd is. Tomcat
> will have continuations some day. But we have to start somewhere... at
> least
> me :-) I'll add my tapestry pages to JIIRA, they expose some bugs (totally
> blows with Firefox 2.0), regardless of if polling is the way to go or not.
> I'll maybe do polling and keep some logic in the client to be able to send
> deltas.
>
> Cheers & always looking forward for you new stuff :-)
>
>
> Jessek wrote:
> >
> > There ~will~ be more features like this soon, have been on the tail end
> of
> > a
> > "rent paying" project release and haven't had time for anything else...
> >
> > I'm not sure polling is the perfect answer (at least done this way.) You
> > might check out cometd.org as well. The dojo + jetty guys have been
> > working
> > together to make this a lot easier for servlet based apps.
> >
> > One of many "to dos" I plan on adding to tapestry at some
> point..(probably
> > a
> > sub project, but will likely happen sooner than later as it seems lots
> of
> > people want this)
> >
> > On 9/6/06, livelock <di...@masse.de> wrote:
> >>
> >>
> >> Yay, it works, thanks. It really looks like there should be a more
> >> elegant
> >> solution to this, but hey, it works.
> >>
> >> Now I am facing a different thing, using AJAX requests I only want to
> >> transfer deltas. For example if there are 11 rows on the screen and on
> >> the
> >> next update there is a new one, I don't want to transfer 12 rows then,
> >> only
> >> one and add it to the other rows.
> >> Is there an elegant way? Or do I have to create component instances
> >> dynamically?
> >>
> >> Regards
> >>
> >>
> >> Josh Long wrote:
> >> >
> >> > The following is contrived, but works. Mainly, I would create a
> proper
> >> > dojo widget and have the event listener bind to that, but this works
> >> > because of expando properties...
> >> >
> >> > In your body of a file called Test.html, I have
> >> >
> >> >
> >> >     <div id ="test"></div>
> >> >
> >> >          <script type="text/javascript" >
> >> >               dojo.require('dojo.lang.*');
> >> >               dojo.require('dojo.event.*')
> >> >             var tst =dojo.byId('test');
> >> >
> >> >                     tst.update=function()
> >> >                       {
> >> >                           dojo.debug ('running')
> >> >                           dojo.lang.setTimeout( tst.update , 4000) ;
> >> > // im sure ther animation package had
> >> > //a proper way of scheduling something for repeating, but...
> >> >                       };
> >> >
> >> >             dojo.addOnLoad(function(){
> >> >                dojo.byId('test').update() ; // get the ball rolling
> >> >             });
> >> >          </script>
> >> >
> >> >     <div jwcid="status@Any">
> >> >               <span jwcid="@Insert" value = "ognl: now">
> >> >               the current time is
> >> >               </span>
> >> >         </div>
> >> >
> >> >
> >> > then in Test.java,
> >> >
> >> >
> >> >     abstract public Date getNow() ;
> >> >     abstract public void setNow(Date now) ;
> >> >
> >> >     @EventListener( elements ="test", async = true ,
> >> >                     events ="update")
> >> >     public void update (IRequestCycle cycle )
> >> >     {
> >> >         setNow(new Date()) ;
> >> >         cycle.getResponseBuilder().updateComponent("status");
> >> >    }
> >> >
> >> >
> >> > and boom!
> >> >
> >> > As you load hte page in javascript, test.update gets called which in
> >> > turn causes the server side event listener to run. The event listener
> >> > updates the clock (every 4 seconds because I was running this in
> devel
> >> > mode and, and I mean nothing, pisses tapestry off more than running
> in
> >> > devel mode) and the page reflects it without any refresh.
> >> >
> >> > Hope this helps, sort of...
> >> >
> >> > Josh
> >> >
> >> > On 9/3/06, livelock <di...@masse.de> wrote:
> >> >>
> >> >> Hi,
> >> >> Dojo got a polling mode
> >> >> (
> >>
> http://archive.dojotoolkit.org/nightly/tests/io/test_ScriptSrcIO.html#CommonArgs
> >> ).
> >> >> How do I use that properly with Tapestry 4.1? The EventListener
> seems
> >> not
> >> >> have anything that ge
> >> >>
> >> >> I want a component that reads a property from a server all 4
> seconds.
> >> For
> >> >> example for stock quotes or even a chat.
> >> >>
> >> >> Regards,
> >> >> André
> >> >> --
> >> >> View this message in context:
> >> >>
> >>
> http://www.nabble.com/How-to-implement-polling-with-%40EventListener-tf2212501.html#a6127728
> >> >> Sent from the Tapestry - User forum at Nabble.com.
> >> >>
> >> >>
> >> >>
> ---------------------------------------------------------------------
> >> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >> >>
> >> >>
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> > For additional commands, e-mail: users-help@tapestry.apache.org
> >> >
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/How-to-implement-polling-with-%40EventListener-tf2212501.html#a6170249
> >> Sent from the Tapestry - User forum at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>
> >>
> >
> >
> > --
> > Jesse Kuhnert
> > Tapestry/Dojo/(and a dash of TestNG), team member/developer
> >
> > Open source based consulting work centered around
> > dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/How-to-implement-polling-with-%40EventListener-tf2212501.html#a6188522
> Sent from the Tapestry - User forum at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Jesse Kuhnert
Tapestry/Dojo/(and a dash of TestNG), team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

Re: How to implement polling with @EventListener

Posted by livelock <di...@masse.de>.
Jesse, thanks for your tremendous efforts! Paying rent is always a good thing
(TM).

You are right of course. Polling is not the way to go
(http://docs.codehaus.org/display/JETTY/Continuations), cometd is. Tomcat
will have continuations some day. But we have to start somewhere... at least
me :-) I'll add my tapestry pages to JIIRA, they expose some bugs (totally
blows with Firefox 2.0), regardless of if polling is the way to go or not.
I'll maybe do polling and keep some logic in the client to be able to send
deltas. 

Cheers & always looking forward for you new stuff :-)


Jessek wrote:
> 
> There ~will~ be more features like this soon, have been on the tail end of
> a
> "rent paying" project release and haven't had time for anything else...
> 
> I'm not sure polling is the perfect answer (at least done this way.) You
> might check out cometd.org as well. The dojo + jetty guys have been
> working
> together to make this a lot easier for servlet based apps.
> 
> One of many "to dos" I plan on adding to tapestry at some point..(probably
> a
> sub project, but will likely happen sooner than later as it seems lots of
> people want this)
> 
> On 9/6/06, livelock <di...@masse.de> wrote:
>>
>>
>> Yay, it works, thanks. It really looks like there should be a more
>> elegant
>> solution to this, but hey, it works.
>>
>> Now I am facing a different thing, using AJAX requests I only want to
>> transfer deltas. For example if there are 11 rows on the screen and on
>> the
>> next update there is a new one, I don't want to transfer 12 rows then,
>> only
>> one and add it to the other rows.
>> Is there an elegant way? Or do I have to create component instances
>> dynamically?
>>
>> Regards
>>
>>
>> Josh Long wrote:
>> >
>> > The following is contrived, but works. Mainly, I would create a proper
>> > dojo widget and have the event listener bind to that, but this works
>> > because of expando properties...
>> >
>> > In your body of a file called Test.html, I have
>> >
>> >
>> >     <div id ="test"></div>
>> >
>> >          <script type="text/javascript" >
>> >               dojo.require('dojo.lang.*');
>> >               dojo.require('dojo.event.*')
>> >             var tst =dojo.byId('test');
>> >
>> >                     tst.update=function()
>> >                       {
>> >                           dojo.debug ('running')
>> >                           dojo.lang.setTimeout( tst.update , 4000) ;
>> > // im sure ther animation package had
>> > //a proper way of scheduling something for repeating, but...
>> >                       };
>> >
>> >             dojo.addOnLoad(function(){
>> >                dojo.byId('test').update() ; // get the ball rolling
>> >             });
>> >          </script>
>> >
>> >     <div jwcid="status@Any">
>> >               <span jwcid="@Insert" value = "ognl: now">
>> >               the current time is
>> >               </span>
>> >         </div>
>> >
>> >
>> > then in Test.java,
>> >
>> >
>> >     abstract public Date getNow() ;
>> >     abstract public void setNow(Date now) ;
>> >
>> >     @EventListener( elements ="test", async = true ,
>> >                     events ="update")
>> >     public void update (IRequestCycle cycle )
>> >     {
>> >         setNow(new Date()) ;
>> >         cycle.getResponseBuilder().updateComponent("status");
>> >    }
>> >
>> >
>> > and boom!
>> >
>> > As you load hte page in javascript, test.update gets called which in
>> > turn causes the server side event listener to run. The event listener
>> > updates the clock (every 4 seconds because I was running this in devel
>> > mode and, and I mean nothing, pisses tapestry off more than running in
>> > devel mode) and the page reflects it without any refresh.
>> >
>> > Hope this helps, sort of...
>> >
>> > Josh
>> >
>> > On 9/3/06, livelock <di...@masse.de> wrote:
>> >>
>> >> Hi,
>> >> Dojo got a polling mode
>> >> (
>> http://archive.dojotoolkit.org/nightly/tests/io/test_ScriptSrcIO.html#CommonArgs
>> ).
>> >> How do I use that properly with Tapestry 4.1? The EventListener seems
>> not
>> >> have anything that ge
>> >>
>> >> I want a component that reads a property from a server all 4 seconds.
>> For
>> >> example for stock quotes or even a chat.
>> >>
>> >> Regards,
>> >> André
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/How-to-implement-polling-with-%40EventListener-tf2212501.html#a6127728
>> >> Sent from the Tapestry - User forum at Nabble.com.
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> >> For additional commands, e-mail: users-help@tapestry.apache.org
>> >>
>> >>
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> > For additional commands, e-mail: users-help@tapestry.apache.org
>> >
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/How-to-implement-polling-with-%40EventListener-tf2212501.html#a6170249
>> Sent from the Tapestry - User forum at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> 
> -- 
> Jesse Kuhnert
> Tapestry/Dojo/(and a dash of TestNG), team member/developer
> 
> Open source based consulting work centered around
> dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-implement-polling-with-%40EventListener-tf2212501.html#a6188522
Sent from the Tapestry - User forum at Nabble.com.


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


Re: How to implement polling with @EventListener

Posted by Jesse Kuhnert <jk...@gmail.com>.
There ~will~ be more features like this soon, have been on the tail end of a
"rent paying" project release and haven't had time for anything else...

I'm not sure polling is the perfect answer (at least done this way.) You
might check out cometd.org as well. The dojo + jetty guys have been working
together to make this a lot easier for servlet based apps.

One of many "to dos" I plan on adding to tapestry at some point..(probably a
sub project, but will likely happen sooner than later as it seems lots of
people want this)

On 9/6/06, livelock <di...@masse.de> wrote:
>
>
> Yay, it works, thanks. It really looks like there should be a more elegant
> solution to this, but hey, it works.
>
> Now I am facing a different thing, using AJAX requests I only want to
> transfer deltas. For example if there are 11 rows on the screen and on the
> next update there is a new one, I don't want to transfer 12 rows then,
> only
> one and add it to the other rows.
> Is there an elegant way? Or do I have to create component instances
> dynamically?
>
> Regards
>
>
> Josh Long wrote:
> >
> > The following is contrived, but works. Mainly, I would create a proper
> > dojo widget and have the event listener bind to that, but this works
> > because of expando properties...
> >
> > In your body of a file called Test.html, I have
> >
> >
> >     <div id ="test"></div>
> >
> >          <script type="text/javascript" >
> >               dojo.require('dojo.lang.*');
> >               dojo.require('dojo.event.*')
> >             var tst =dojo.byId('test');
> >
> >                     tst.update=function()
> >                       {
> >                           dojo.debug ('running')
> >                           dojo.lang.setTimeout( tst.update , 4000) ;
> > // im sure ther animation package had
> > //a proper way of scheduling something for repeating, but...
> >                       };
> >
> >             dojo.addOnLoad(function(){
> >                dojo.byId('test').update() ; // get the ball rolling
> >             });
> >          </script>
> >
> >     <div jwcid="status@Any">
> >               <span jwcid="@Insert" value = "ognl: now">
> >               the current time is
> >               </span>
> >         </div>
> >
> >
> > then in Test.java,
> >
> >
> >     abstract public Date getNow() ;
> >     abstract public void setNow(Date now) ;
> >
> >     @EventListener( elements ="test", async = true ,
> >                     events ="update")
> >     public void update (IRequestCycle cycle )
> >     {
> >         setNow(new Date()) ;
> >         cycle.getResponseBuilder().updateComponent("status");
> >    }
> >
> >
> > and boom!
> >
> > As you load hte page in javascript, test.update gets called which in
> > turn causes the server side event listener to run. The event listener
> > updates the clock (every 4 seconds because I was running this in devel
> > mode and, and I mean nothing, pisses tapestry off more than running in
> > devel mode) and the page reflects it without any refresh.
> >
> > Hope this helps, sort of...
> >
> > Josh
> >
> > On 9/3/06, livelock <di...@masse.de> wrote:
> >>
> >> Hi,
> >> Dojo got a polling mode
> >> (
> http://archive.dojotoolkit.org/nightly/tests/io/test_ScriptSrcIO.html#CommonArgs
> ).
> >> How do I use that properly with Tapestry 4.1? The EventListener seems
> not
> >> have anything that ge
> >>
> >> I want a component that reads a property from a server all 4 seconds.
> For
> >> example for stock quotes or even a chat.
> >>
> >> Regards,
> >> André
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/How-to-implement-polling-with-%40EventListener-tf2212501.html#a6127728
> >> Sent from the Tapestry - User forum at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/How-to-implement-polling-with-%40EventListener-tf2212501.html#a6170249
> Sent from the Tapestry - User forum at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Jesse Kuhnert
Tapestry/Dojo/(and a dash of TestNG), team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

Re: How to implement polling with @EventListener

Posted by livelock <di...@masse.de>.
Yay, it works, thanks. It really looks like there should be a more elegant
solution to this, but hey, it works.

Now I am facing a different thing, using AJAX requests I only want to
transfer deltas. For example if there are 11 rows on the screen and on the
next update there is a new one, I don't want to transfer 12 rows then, only
one and add it to the other rows.
Is there an elegant way? Or do I have to create component instances
dynamically?

Regards


Josh Long wrote:
> 
> The following is contrived, but works. Mainly, I would create a proper
> dojo widget and have the event listener bind to that, but this works
> because of expando properties...
> 
> In your body of a file called Test.html, I have
> 
> 
>     <div id ="test"></div>
> 
>          <script type="text/javascript" >
>               dojo.require('dojo.lang.*');
>               dojo.require('dojo.event.*')
>             var tst =dojo.byId('test');
> 
>                     tst.update=function()
>                       {
>                           dojo.debug ('running')
>                           dojo.lang.setTimeout( tst.update , 4000) ;
> // im sure ther animation package had
> //a proper way of scheduling something for repeating, but...
>                       };
> 
>             dojo.addOnLoad(function(){
>                dojo.byId('test').update() ; // get the ball rolling
>             });
>          </script>
> 
>     <div jwcid="status@Any">
>               <span jwcid="@Insert" value = "ognl: now">
>               the current time is
>               </span>
>         </div>
> 
> 
> then in Test.java,
> 
> 
>     abstract public Date getNow() ;
>     abstract public void setNow(Date now) ;
> 
>     @EventListener( elements ="test", async = true ,
>                     events ="update")
>     public void update (IRequestCycle cycle )
>     {
>         setNow(new Date()) ;
>         cycle.getResponseBuilder().updateComponent("status");
>    }
> 
> 
> and boom!
> 
> As you load hte page in javascript, test.update gets called which in
> turn causes the server side event listener to run. The event listener
> updates the clock (every 4 seconds because I was running this in devel
> mode and, and I mean nothing, pisses tapestry off more than running in
> devel mode) and the page reflects it without any refresh.
> 
> Hope this helps, sort of...
> 
> Josh
> 
> On 9/3/06, livelock <di...@masse.de> wrote:
>>
>> Hi,
>> Dojo got a polling mode
>> (http://archive.dojotoolkit.org/nightly/tests/io/test_ScriptSrcIO.html#CommonArgs).
>> How do I use that properly with Tapestry 4.1? The EventListener seems not
>> have anything that ge
>>
>> I want a component that reads a property from a server all 4 seconds. For
>> example for stock quotes or even a chat.
>>
>> Regards,
>> André
>> --
>> View this message in context:
>> http://www.nabble.com/How-to-implement-polling-with-%40EventListener-tf2212501.html#a6127728
>> Sent from the Tapestry - User forum at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-implement-polling-with-%40EventListener-tf2212501.html#a6170249
Sent from the Tapestry - User forum at Nabble.com.


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


Re: How to implement polling with @EventListener

Posted by Josh Long <st...@gmail.com>.
The following is contrived, but works. Mainly, I would create a proper
dojo widget and have the event listener bind to that, but this works
because of expando properties...

In your body of a file called Test.html, I have


    <div id ="test"></div>

         <script type="text/javascript" >
              dojo.require('dojo.lang.*');
              dojo.require('dojo.event.*')
            var tst =dojo.byId('test');

                    tst.update=function()
                      {
                          dojo.debug ('running')
                          dojo.lang.setTimeout( tst.update , 4000) ;
// im sure ther animation package had
//a proper way of scheduling something for repeating, but...
                      };

            dojo.addOnLoad(function(){
               dojo.byId('test').update() ; // get the ball rolling
            });
         </script>

    <div jwcid="status@Any">
              <span jwcid="@Insert" value = "ognl: now">
              the current time is
              </span>
        </div>


then in Test.java,


    abstract public Date getNow() ;
    abstract public void setNow(Date now) ;

    @EventListener( elements ="test", async = true ,
                    events ="update")
    public void update (IRequestCycle cycle )
    {
        setNow(new Date()) ;
        cycle.getResponseBuilder().updateComponent("status");
   }


and boom!

As you load hte page in javascript, test.update gets called which in
turn causes the server side event listener to run. The event listener
updates the clock (every 4 seconds because I was running this in devel
mode and, and I mean nothing, pisses tapestry off more than running in
devel mode) and the page reflects it without any refresh.

Hope this helps, sort of...

Josh

On 9/3/06, livelock <di...@masse.de> wrote:
>
> Hi,
> Dojo got a polling mode
> (http://archive.dojotoolkit.org/nightly/tests/io/test_ScriptSrcIO.html#CommonArgs).
> How do I use that properly with Tapestry 4.1? The EventListener seems not
> have anything that ge
>
> I want a component that reads a property from a server all 4 seconds. For
> example for stock quotes or even a chat.
>
> Regards,
> André
> --
> View this message in context: http://www.nabble.com/How-to-implement-polling-with-%40EventListener-tf2212501.html#a6127728
> Sent from the Tapestry - User forum at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

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