cf_progress: indicating progress with large operations
The Out of Site Mailer uses CFQuery to go over a large number of emailaddresses. I use CFFLUSH to output the progress to the browser, but just dumping each and every mailaddress to the screen doesn't give a good clue as to where we are and how long this will take.
I've created <cf_progress> which indicates in a Windows progressbar style what's happening, like this:


It uses cfflush first of all to flush loaded data onto the screen at a specific interval. Than it calls the main progress.cfm file to load the progressbar, and at each change it loads the the "counter" which updates the progress bar.
SELECT Email, Firstname, Lastname from tblRecipients
WHERE Category = "newsletter"
</cfquery>
<cfflush interval="10">
<cf_Progress maxvalue="#recipientlist.recordcount#">
<cfloop query="RecipientList">
<cf_ProgressCount current="#recipientlist.currentrow#">
</cfloop>
You load up cf_progress with the maxvalue attribute, which basically is the maximum number it will reach. To not make your browser run through to much code, it will update the progressbar at specific intervals. For instance, with a recordcount between 100 and 1.000 the bar will be updated every 5th record, over a 100.000 it will only update at every 1.000th record. This way you prevent your page from being swamped with javascript data.
the cf_progresscount needs a "current" numeric value to indicate where in the scale of things the progressbar currently is.
Attached you will find the zip-file with the 2 progress files (copy to your CFMX Custom Tags) and 2 example files (the above code example and a real-time lengthy cfflush operation to really demonstrate the use).
» start download «
Note: this tag isn't XHTML compatible, haven't had the time to make this so. It's because of the way the layers are (mis)used to get this working.

