For the complete experience, please enable JavaScript in your browser. Thank you!

  • Creative Cloud
  • Photoshop
  • Illustrator
  • InDesign
  • Premiere Pro
  • After Effects
  • Lightroom
  • See all
  • See plans for: businesses photographers students
  • Document Cloud
  • Acrobat DC
  • eSign
  • Stock
  • Elements
  • Marketing Cloud
  • Analytics
  • Audience Manager
  • Campaign
  • Experience Manager
  • Media Optimizer
  • Target
  • See all
  • Acrobat Reader DC
  • Adobe Flash Player
  • Adobe AIR
  • Adobe Shockwave Player
  • All products
  • Creative Cloud
  • Individuals
  • Photographers
  • Students and Teachers
  • Business
  • Schools and Universities
  • Marketing Cloud
  • Document Cloud
  • Stock
  • Elements
  • All products
  • Get Support
    Find answers quickly. Contact us if you need to.
    Start now >
  • Learn the apps
    Get started or learn new ways to work.
    Learn now >
  • Ask the community
    Post questions and get answers from experts.
    Start now >
    • About Us
    • Careers At Adobe
    • Investor Relations
    • Privacy  |  Security
    • Corporate Responsibility
    • Customer Showcase
    • Events
    • Contact Us
News
    • 3/22/2016
      Adobe Summit 2016: Are You An Experience Business?
    • 3/22/2016
      Adobe Announces Cross-Device Co-op to Enable People-Based Marketing
    • 3/22/2016
      Adobe and comScore Advance Digital TV and Ad Measurement
    • 3/22/2016
      Adobe Marketing Cloud Redefines TV Experience
Using Ajax User Interface Components and Features / 

Using the cfprogressbar tag

Adobe Community Help


Applies to

  • ColdFusion

Contact support

 
By clicking Submit, you accept the Adobe Terms of Use.
 

The cfprogressbar tag has the following characteristics:

  • Automatically runs the progress bar for a duration that you specify.
  • Dynamically loads data using bind expressions
  • Lets styling of the progress bar
  • Uses callback and error handlers that give control to the users after the progress bar completes processing or if it encounters any exceptions.
  • Lets programmatic control over progress bar using JavaScript APIs.

Progress bar modes

The progress bar supports the following two modes:

Dynamic mode

User specifies the bind expression to provide data for the progress bar to display. The bind attribute specifies a function that determines the indicator length.The following CFM code shows how to use a CFC bind expression:

<cfajaxproxy cfc="pbar" jsclassname="pbar">
<head>
<script>
var utils = new pbar();
var count = 0;
var init = function()
{
document.getElementById('cfpbLabel').style.display = 'block';
ColdFusion.ProgressBar.show('pBar');
ColdFusion.ProgressBar.start('pBar');
}
var hideProgessBar = function()
{
document.getElementById('cfpbLabel').style.display = 'none';
ColdFusion.ProgressBar.hide('pBar');
utils.resetStatus();
}
</script>
</head>
<cfform>
<div id="cfpbLabel" style="display:none">
Saving File:
</div>
<cfprogressbar
name="pBar"
autodisplay=false
bind="cfc:pbar.getProgessData()"
onComplete="hideProgessBar"
width="400" >
<cfset ajaxOnLoad('init')>
</cfform>

The following pb.cfc has the function that returns data for the progressbar:

<cfcomponent>
<cffunction name="resetStatus" access="remote">
<!---
Clear count from session so that next time the progress bar runs from the start time.
--->
<cfif session.count gte 10>
<cfset structdelete(session,"count")>
</cfif>
</cffunction>
<cffunction name="getProgessData" access="remote">
<!--- use a count to track progress --->
<cfif not isdefined('session.count')>
<cfset session.count = 1>
<cfelse>
<cfset session.count = session.count + 1 >
</cfif>
<!--- struct with status and message components of the progressbar --->
<cfset data = {status=session.count * 0.1,message=(session.count * 10) & "%"}>
<cfreturn data>
</cffunction>
</cfcomponent>

The following CFM code explains how to use the URL bind expression:

<head>
<script>
var init = function()
{
document.getElementById('cfpbLabel').style.display = 'block';
ColdFusion.ProgressBar.show('pBar');
ColdFusion.ProgressBar.start('pBar');
}
var hideProgessBar = function()
{
document.getElementById('cfpbLabel').style.display = 'none';
ColdFusion.ProgressBar.hide('pBar');
}
</script>
</head>
<cfform>
<div id="cfpbLabel" style="display:none">
Saving File:
</div>
<cfprogressbar
name="pBar"
autodisplay=false
bind="url:progressdata.cfm"
onComplete="hideProgessBar"
width="400" >
<cfset ajaxOnLoad('init')>
</cfform>

The following is the Progressdata.cfm:

<!--- use a count to indicate progress --->
<cfif not isdefined('session.count')>
<cfset session.count = 1>
<cfelse>
<cfset session.count = session.count + 1 >
</cfif>
<!--- the struct to be sent back; using the populate the status and message components of the progressbar --->
<cfset data = {status=session.count * 0.1,message=(session.count * 10) & "%"}>
<!--- clear count from session to start afresh the next time the program is run --->
<cfif session.count eq 10>
<cfset structdelete(session,"count")>
</cfif>
<!--- data sent back via URL binds must use SerializeJSON() --->
<cfoutput>#SerializeJSON(data)#</cfoutput>

The following CFM code has the JavaScript bind expression:

<head>
<script>
var count = 0;
var init = function()
{
document.getElementById('cfpbLabel').style.display = 'block';
ColdFusion.ProgressBar.show('pBar');
ColdFusion.ProgressBar.start('pBar');
}
var hideProgessBar = function()
{
document.getElementById('cfpbLabel').style.display = 'none';
ColdFusion.ProgressBar.hide('pBar');
}
var getProgessData = function()
{
count++;
if(count > 10)
return {STATUS:1,MESSAGE:"Done"}
else
return {STATUS:count*0.1,MESSAGE:(count * 10) + "%"}
}
</script>
</head>
<cfform>
<div id="cfpbLabel" style="display:none">
Saving File:
</div>
<cfprogressbar
name="pBar"
autodisplay=false
bind="javascript:getProgessData()"
onComplete="hideProgessBar"
width="400"
>
<cfset ajaxOnLoad('init')>
</cfform>

Manual mode

In the manual mode, you specify the duration the progress bar takes to complete the display of progress. In the following example, autodisplay is set to false as a result of which the progress bar is not shown when the page is first loaded. When the page is loaded, init function is invoked and the function displays and runs the progress bar. The default interval used in this mode is one second.

<head>
<script>
var init = function()
{
document.getElementById('cfpbLabel').style.display = 'block';
ColdFusion.ProgressBar.show('pBar');
ColdFusion.ProgressBar.start('pBar');
}
var hideProgessBar = function(){
document.getElementById('cfpbLabel').style.display = 'none';
ColdFusion.ProgressBar.hide('pBar');
}
</script>
</head>
<cfform>
<div id="cfpbLabel" style="display:none">
Saving File:
</div>
<cfprogressbar
name="pBar"
duration="10000"
autodisplay=false
onComplete="hideProgessBar"
width="400"
/>
<cfset ajaxOnLoad('init')>
</cfform>

Working with a progress bar at runtime

This section illustrates how to use the JavaScript API to update the progress bar status. The following CFM code loads a progress bar using the JavaScript API ColdFusion.ProgressBar.updatestatus.
On program load, intit function displays the progress bar and calls the getProgressData JavaScript function to manually update the progress bar. The getProgressData function assigns the status and message variables passed to the JavaScript API update status. 
While working with a progress bar at runtime, ensure that you specify a dummy duration (for instance, duration=5000). Even though the custom JavaScript function decides the actual duration, duration is a mandatory attribute.

<cfajaxproxy cfc="pbar" jsclassname="pbar">
<head>
<script>
var utils = new pbar();
var init = function()
{
document.getElementById('cfpbLabel').style.display = 'block';
ColdFusion.ProgressBar.show('pBar');
getProgessData();
}
var hideProgessBar = function()
{
document.getElementById('cfpbLabel').style.display = 'none';
ColdFusion.ProgressBar.hide('pBar');
}
var getProgessData = function()
{
for(i=1;i <= 10;i++)
{
var status = parseFloat(i * 0.10);
var message = Math.round(status * 100) + "%";
ColdFusion.ProgressBar.updateStatus('pBar',status,message);
utils.sleep(1000);
}
hideProgessBar();
}
</script>
</head>
<cfform>
<div id="cfpbLabel" style="display:none">
Saving File:
</div>
<cfprogressbar
name="pBar"
autodisplay=false
duration=15000
onComplete="hideProgessBar"
width="400" >
<cfset ajaxOnLoad('init')>
</cfform>

The sleep function in the following CFC provides sleep functionality in the JavaScript code:

<cfcomponent>
<cffunction name="sleep" access="remote">
<cfargument name="timetosleep" default="1000">
<cfset sleep(timetosleep)>
</cffunction>
</cfcomponent>

Styling the progress bar

The cfprogressbar has style attribute that lets you decide:

  • Background color of the progress bar
  • Color of the progress message
  • Color of the progress indicator
    The following code illustrates styling: style="bgcolor:ADD8E6;progresscolor:6183A6;textcolor:191970"

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy

Choose your region United States (Change)   Products   Downloads   Learn & Support   Company
Choose your region Close

Americas

Europe, Middle East and Africa

Asia Pacific

  • Brasil
  • Canada - English
  • Canada - Français
  • Latinoamérica
  • México
  • United States
  • Africa - English
  • Österreich - Deutsch
  • Belgium - English
  • Belgique - Français
  • België - Nederlands
  • България
  • Hrvatska
  • Cyprus - English
  • Česká republika
  • Danmark
  • Eesti
  • Suomi
  • France
  • Deutschland
  • Greece - English
  • Magyarország
  • Ireland
  • Israel - English
  • ישראל - עברית
  • Italia
  • Latvija
  • Lietuva
  • Luxembourg - Deutsch
  • Luxembourg - English
  • Luxembourg - Français
  • Malta - English
  • الشرق الأوسط وشمال أفريقيا - اللغة العربية
  • Middle East and North Africa - English
  • Moyen-Orient et Afrique du Nord - Français
  • Nederland
  • Norge
  • Polska
  • Portugal
  • România
  • Россия
  • Srbija
  • Slovensko
  • Slovenija
  • España
  • Sverige
  • Schweiz - Deutsch
  • Suisse - Français
  • Svizzera - Italiano
  • Türkiye
  • Україна
  • United Kingdom
  • Australia
  • 中国
  • 中國香港特別行政區
  • Hong Kong S.A.R. of China
  • India - English
  • 日本
  • 한국
  • New Zealand
  • Southeast Asia (Includes Indonesia, Malaysia, Philippines, Singapore, Thailand, and Vietnam) - English
  • 台灣

Commonwealth of Independent States

  • Includes Armenia, Azerbaijan, Belarus, Georgia, Moldova, Kazakhstan, Kyrgyzstan, Tajikistan, Turkmenistan, Ukraine, Uzbekistan

Copyright © 2016 Adobe Systems Incorporated. All rights reserved.

Terms of Use | Privacy | Cookies

AdChoices