Accessibility

ColdFusion Article

 

Employee Updater: Building a Client-Server Application with Macromedia Flash Data Connection Wizard and ColdFusion


Ben Forta

Ben Forta

forta.com

Table of Contents

Created:
17 February 2004
User Level:
Intermediate

Macromedia Flash has been a capable client computing platform for quite some time, and ever since Macromedia Flash MX, integration with ColdFusion has been clean and simple. But recently released Macromedia Flash MX Professional 2004 Wizards make the process of building ColdFusion-powered Flash applications easier than ever, as this article will demonstrate.

Note: This article assumes a good working knowledge of ColdFusion, use of ColdFusion MX, and basic familiarity with ColdFusion Components.

Some Basics

For many of us, the word "Flash" still conjures up images of slow downloads, often extraneous animation, overly intrusive pop-up ads, and "Skip Intro." That's a shame. While Flash has proven itself invaluable in the graphics and design department, and indeed that is where its origins lie, Flash player can do so much more. In fact, since the release of Flash MX (and now with Flash MX Professional 2004), developers from a variety of backgrounds are discovering that Flash has legitimate and unparalleled value in application development in general.

The Flash player runs Flash files (SWF files), which you create using the Flash IDE (lots of uses of the word Flash, and thus, frequent confusion as to what exactly we're referring to at any given time). Players are available for all sorts of operating systems and devices and platforms, and the same SWF files run in exactly the same way on each. This makes Flash a very compelling alternative to HTML and DHTML, which is anything but portable. In addition, as the Flash player is a thin-but-not-as-thin-as-the-browser client, the player is capable of so much more than plain old HTML (even HTML plus client-side scripting).

But Flash runs on the client, not on the server. Flash therefore cannot access databases on the server, and cannot generate e-mail messages or authenticate user logins. All of these require communication between Flash on the client and a back-end server. And Macromedia has built this capability—being able to communicate to back-end servers—right into Flash player.

As such, you can use Flash as a client in client-server style development, both as an alternative to specific elements in an HTML page, and as a replacement for complete HTML application front ends.

Note: To follow along you'll need to be running Flash MX Professional 2004 with the latest updates and wizards installed. See more in the Getting Set Up section.

What You'll Build

The best way to understand Flash applications and how they relate to ColdFusion is to build a sample application. This article does not cover every Flash feature and option and only uses a few of the included components; refer to the included documentation for complete component coverage and extensive examples. Having said that, I'll guide you through building a complete application. The application will be a data-entry front end for a user database and will feature:

  • A data grid for browsing and scrolling through a list of users
  • A related data grid with a master/detail view
  • Integrated user login processing
  • The ability to edit existing users and to insert and delete users
  • Batch database updating

…all without browser screen refreshes!

Ready? Great, we're about to begin, but first some setup details.

Requirements

To complete this tutorial you will need to install the following software and files:

ColdFusion MX Standard, Enterprise, or Developer Edition

  • Install the example applications (the database this tutorial uses the same database as the example applications).
  • Apply the latest ColdFusion updater

Flash MX Professional 2004

A couple of important notes on your Flash installation:

  • Install the Flash MX Professional 2004 patches and updates. In particular, make sure you have the Flash MX Professional 2004 updater released on November 10, 2003.
  • You need to have professional version of Flash. If you need to upgrade your Flash MX 2004 version to Flash MX Professional 2004, Open Flash MX 2004 and go to Help > Upgrade to Flash MX Professional 2004. Click Continue to try or buy Macromedia Flash MX Professional 2004 and enter a serial number. You must quit and restart Flash MX Professional 2004 again for the upgrade to take effect.

Dreamweaver MX 2004

Data Connection Wizard and DataGrid Column Editor Extensions

You can download the Data Connection Wizard and DataGrid Column Editor extensions from Macromedia Exchange. Here's how you get them:

Before installing the extensions, download and install the most recent Extension Manager.

Download the following extensions:

Tutorials and sample files:


The sample files in ZIP contain the complete code for this application. Instead of using the solution files for this application, I suggest you build the code along with me. I'll tell you when you need to refer to the solution files near the end of this tutorial.

Completing the Installation

To ensure that you have installed the extensions, open any Flash document in Flash MX Professional 2004. Go to the Commands menu. If the they are installed, you'll see a menu option called Data Connection Wizard. For this tutorial, you use the DataGrid Column editor through the Data Connection Wizard and therefore it does not appear in the Commands menu.

If you have all the software installed, continue with these steps:

  1. Create a new folder called cfflash under your webroot for the application. The instructions provided here assume that you'll be using ColdFusion MX with the integrated HTTP server on port 8500.
  2. Create a ColdFusion file named employees.cfc in your cfflash application directory. You'll add methods to this file shortly.

About the author

Ben Forta is the Adobe senior product evangelist and the author of numerous books, including ColdFusion Web Application Construction Kit and its sequel Advanced ColdFusion Application Development, as well as books on SQL, JavaServer Pages, WAP, Windows development, and more. Ben co-authored the official ColdFusion training material, the certification tests and Macromedia Press study guides for those tests, and now spends a considerable amount of time lecturing, speaking, and writing about application development worldwide. Visit Ben's blog to read his regular postings on ColdFusion and more.