Agile Ajax

Adding a Timer Component to Echo2

One of the things I really like about ZK is that it has a timer component that you can add or remove from a page in order to enable "async" Ajax events in the application. It's a useful abstraction that hides much of the messiness of async update.

<window title="Timer demo" border="normal">
<label id="now"/><timer id="timer" delay="1000" repeats="true"
onTimer="now.setValue(new Date().toString())"/>
<separator bar="true"/>
<button label="Stops timer" onClick="timer.stop()"/>
<button label="Starts timer" onClick="timer.start()"/>
</window>

Echo2 also has a facility for performing async updates, but it's much more of a roll your own type of facility. I've been wrestling with how to add a timer component to Echo2.

The basic idea is to override the ApplicationInstance as detailed here to allow adding in periodic update tasks. Next, every time a component is registered or unregistered with the ApplicationInstance -- i.e. added or removed from the component heirarchy -- it is added or removed from the periodic update tasks. Fortunately, there are two Echo2 Component lifecycle methods which look like they will work: init() and dispose(). These get called when components get added or removed from a registered heirarchy.

It would be nice if, beyond these two methods, we had something like Swing's HeirarchyEvent and HeirarchyEventListener that allowed us to pass other kinds of events to a heirarchy. Well, the juices are starting to flow again for me on Echo2. I guess it's time to get back to part 2 of the tutorial series.


Technorati : , ,

Comments: 1 so far

  1. Hi Dietrich -

    We have been contemplating of using Echo2 in one of our RIA applications. It is implementation of a Web based Report Designer. I have gone through Echo2 and after a careful assessment versus GWT, have been thinking of using Echo2 for development. I have some concerns though which I have blogged about in http://debasishg.blogspot.com/2006/11/ria-echo2-and-programming-model.html. Would like to have ur opinion and suggestions.

    Cheers.
    - Debasish

    Comment by Debasish Ghosh, Monday, November 20, 2006 @ 12:06 am

Leave a comment

Powered by WP Hashcash

About Pathfinder

  • We design and build extraordinary applications for companies looking to make the next great idea a reality.
  • learn more

Topics

WordPress

Comments about this site: info@pathf.com