[Tip] Showing status with an animated gif
by David Workman
Data Mosaic
Some operations take a while to complete -- looping through a set of records, retrieving records using a custom query, querying a web service, etc. An often used way to denote progress in these operations is to use the progress bar bean. This method works quite well when you are in a looping method but the downsides are that it requires a screen redraw to update -- application.updateUI() -- which can really slow things down. Also, what do you do for those instances where it takes a few seconds (or longer) for just one line of code to complete?
One option is to use Marcel's dialog plugin which has a function that shows the default Mac "spinner" which is a neat effect.
Another is to use an animated gif. Animated gifs are treated just like regular graphics in the Servoy image library and can be assigned to objects on your forms the same way. Which includes assigning them dynamically within a method. Example:
elements.status.setImageURL("media:///status_animation.gif")
So it is simply a matter of assigning an element on your form to an animated gif at the beginning of a process that you know will take some time to complete and then setting it back to the original graphic (or null) when the line of code is done.
Voila!
Comments (4)