Wicket component to count up to a value, then refresh its value from the server

On the avaaz website there is a nice animation to display the number of users the site currently has. The animation is a number, which:

  • Initially, counts up from 0 to the current number of users client-side, taking a few minutes
  • Thereafter, refreshes its value from the server regularly, increasing its value as new users register.

I needed something similar for a project I’m working on, so I’ve written a Wicket component to do it.

It’s perhaps not the most revolutionary component ever! But maybe it’s useful to someone. It’s available under the GPL.

CountingUpThenAutoRefreshingLabel  JavaDoc | Download.

The above example counts up to 1M and then the “refresh” is faked, for this example, by being a number which slowly increases; imagine it’s the number of users the site has, or similar. (It wouldn’t normally be in an iframe either; that is a consequence of the fact this blog is WordPress not Wicket.)

I think this is a good animation in terms of keeping the server load low. Initially, there are no server calls as the animation is done client-side (the normal use case that the page won’t be open long). The second phase re-queries the server at an interval, however this interval gets longer (i.e. the updates become slower), so that the other use case (user opens the browser and goes to lunch) also won’t result in N users hitting the server every 2 seconds for the rest of time.

Wicket 1.4–1.5, Java 1.6

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

For inserting HTML or XML please remember to use &lt; instead of <