ColdFusion 9 Essential Training
Illustration by Richard Downs

Deleting data with ORM


ColdFusion 9 Essential Training

with David Gassner

Start your free trial now, and begin learning software, business and creative skills—anytime, anywhere—with video instruction from recognized industry experts.

Start Your Free Trial Now

Video: Deleting data with ORM

In the current state of my index.cfm page in my Photographers folder of the application, I'm letting the user click a link to select a record to delete. I'm then using the ColdFusion MessageBox tool to let them confirm or cancel the operation. To actually delete the data from the backend database, I'm going to cause the page to navigate to a separate page that will execute an ORM function that removes the data from the backend database table. I will start an index.cfm in the doDelete callback function.
Expand all | Collapse all
  1. 5m 55s
    1. Welcome
      1m 24s
    2. Using the exercise files
      2m 50s
    3. Overview
      1m 41s
  2. 35m 16s
    1. Understanding application servers
      7m 3s
    2. Installing ColdFusion 9 on Windows
      5m 28s
    3. Installing ColdFusion 9 on Mac OS X
      6m 20s
    4. Completing the Configuration wizard
      1m 50s
    5. Starting and stopping ColdFusion on Windows
      4m 7s
    6. Starting and stopping ColdFusion on Mac OS X
      2m 37s
    7. Installing ColdFusion Builder on Windows
      4m 13s
    8. Installing ColdFusion Builder on Mac OS X
      2m 1s
    9. Setting folder permissions on Mac OS X
      1m 37s
  3. 45m 34s
    1. Using Eclipse perspectives and views
      5m 42s
    2. Defining a ColdFusion server
      8m 42s
    3. Creating a ColdFusion project
      4m 40s
    4. Creating and browsing a ColdFusion page
      5m 36s
    5. Defining a default page template
      3m 58s
    6. Setting and outputting variables
      7m 55s
    7. Using the Snippets view
      4m 49s
    8. Using an external browser
      2m 8s
    9. Using online help
      2m 4s
  4. 35m 49s
    1. Adding numbers and concatenating strings
      8m 7s
    2. Using Debug Output
      6m 10s
    3. Inspecting variables with ‹cfdump›
      4m 55s
    4. Using arrays
      5m 21s
    5. Using structures
      3m 51s
    6. Configuring the line debugger
      1m 25s
    7. Using the line debugger
      6m 0s
  5. 53m 45s
    1. Scripting an Apache Derby database
      3m 34s
    2. Defining a data source in ColdFusion Administrator
      6m 13s
    3. Exploring data sources in RDS Dataview
      4m 2s
    4. Using SQL and the ‹cfquery› tag
      6m 58s
    5. Outputting data from a query object
      4m 2s
    6. Outputting a dynamic HTML table from a query
      7m 0s
    7. Generating alternating row colors
      6m 55s
    8. Creating an application directory and home page
      5m 26s
    9. Displaying data on the home page
      5m 43s
    10. Redirecting requests with ‹cflocation›
      3m 52s
  6. 32m 17s
    1. Including pages with ‹cfinclude›
      4m 21s
    2. Creating reusable header and footer files with ‹cfinclude›
      4m 39s
    3. Creating and calling custom tags
      3m 8s
    4. Passing data into custom tags
      2m 34s
    5. Setting default values for custom tag attributes
      4m 51s
    6. Calling custom tags with ‹cfmodule›
      3m 54s
    7. Using a custom tag as a website header
      3m 55s
    8. Creating an application template file
      4m 55s
  7. 52m 6s
    1. Creating a ColdFusion Component (CFC)
      5m 6s
    2. Declaring CFC functions
      3m 28s
    3. Calling CFC methods with ‹cfinvoke›
      2m 28s
    4. Using CFC properties
      4m 51s
    5. Passing data into functions
      3m 38s
    6. Creating and calling CFCs with script syntax
      5m 25s
    7. Generating data access CFCs in ColdFusion Builder
      4m 35s
    8. Calling generated data access methods
      7m 41s
    9. Creating a dynamic HTML table from an array
      8m 8s
    10. Creating an Application.cfc file
      3m 11s
    11. Using an application data source variable
      3m 35s
  8. 32m 56s
    1. Generating an ORM map component
      7m 58s
    2. Enabling an application to use ORM
      1m 58s
    3. Retrieving data with ORM
      2m 55s
    4. Generating mappings for multiple tables
      4m 22s
    5. Filtering data with ORM
      5m 35s
    6. Displaying result data with a custom tag
      10m 8s
  9. 27m 58s
    1. Passing URL variables in hyperlinks
      6m 13s
    2. Passing multiple URL variables
      2m 50s
    3. Encoding URLs with URLEncodedFormat()
      4m 12s
    4. Checking for available variables with isDefined()
      2m 41s
    5. Creating a data-driven hyperlink
      5m 4s
    6. Displaying selected data in a detail page
      6m 58s
  10. 40m 36s
    1. Using HTML data entry forms
      6m 53s
    2. Processing form variables
      3m 24s
    3. Creating self-posting forms with ‹cfform›
      4m 40s
    4. Creating a search interface
      3m 9s
    5. Processing complex queries with HQL
      8m 53s
    6. Creating a dynamic pulldown list with ‹cfselect›
      7m 16s
    7. Displaying form results
      6m 21s
  11. 43m 45s
    1. Building a data entry form for managing data
      5m 15s
    2. Preparing an ORM mapping for inserting data
      3m 47s
    3. Inserting data with ORM
      5m 23s
    4. Retrieving data for an update form
      4m 16s
    5. Populating form controls with existing data
      5m 2s
    6. Updating data with ORM
      2m 56s
    7. Confirming actions with an Ajax message box
      7m 21s
    8. Using JavaScript callback functions
      3m 15s
    9. Deleting data with ORM
      6m 30s
  12. 9m 37s
    1. Defining client-side form validation rules
      4m 14s
    2. Validating on the server with custom CFML
      5m 23s
  13. 18m 9s
    1. Using the Application.cfc onRequest() method
      4m 12s
    2. Creating and using a login form
      4m 53s
    3. Authenticating users with ‹cflogin›
      6m 1s
    4. Logging out users
      3m 3s
  14. 7m 11s
    1. Configuring an FTP site
      2m 27s
    2. Setting a ColdFusion project's synchronization connection
      2m 17s
    3. Uploading files to the production server
      2m 27s
  15. 46s
    1. Goodbye

please wait ...
Watch the Online Video Course ColdFusion 9 Essential Training
7h 21m Beginner Oct 05, 2009

Viewers: in countries Watching now:

ColdFusion 9 Essential Training is a detailed overview of ColdFusion, demonstrating each of the components and tools necessary to create dynamic web sites and web applications. Author and web developer David Gassner starts this course at the very beginning: how to set up a ColdFusion application server in both the Windows and Mac OS X operating systems. Using the new ColdFusion Builder, David explains the data types and code necessary to build and deploy dynamic web pages. Throughout the course, he shows how to build web pages and forms and populate these containers with dynamic data using ColdFusion ORM (Object Relational Mapping), a new feature of ColdFusion 9. Exercise files accompany this course.

Topics include:
  • Using ColdFusion Builder to define a default page template
  • Defining a data source with ColdFusion Administrator
  • Creating data access ColdFusion Components (CFCs) in ColdFusion Builder
  • Using ColdFusion ORM (Object Relational Mapping)
  • Applying dynamically developed URLs to datasets
  • Validating data entry forms and defining client-side validation rules
  • Using JavaScript callback functions to present and manipulate AJAX-style user interface components
Developer Web
David Gassner

Deleting data with ORM

In the current state of my index.cfm page in my Photographers folder of the application, I'm letting the user click a link to select a record to delete. I'm then using the ColdFusion MessageBox tool to let them confirm or cancel the operation. To actually delete the data from the backend database, I'm going to cause the page to navigate to a separate page that will execute an ORM function that removes the data from the backend database table. I will start an index.cfm in the doDelete callback function.

I currently have a call to the JavaScript alert method there, which is just reporting which button was clicked. I will comment that code out, placing a pair of slashes at the beginning of the line and then I will place the cursor on a new line. I'll start with an if clause. I'll check the value of the btn variable for a value of Yes. Remember the JavaScript returns this value as all lowercase, so it will be either yes or no lowercase.

And then, I'll create a pair of curly braces and if that condition is true, I will then navigate to a new page and pass the value of the photographer ID that was selected by the user. I will use this JavaScript code, document.location =, and then I will pass the name of a ColdFusion page that I need to create, delete.cfm. This page will expect a variable called photographerid in the URL scope. So, I will add a question mark after the page name and the name of the variable, photographerid, and an equals operator.

Then I'll put a plus operator at the end of the line after the quote. In JavaScript you use the plus operator for concatenation. That's in contrast to ColdFusion, which uses the ampersand and then I will pass in the value of the JavaScript photographerid variable that I created and populated earlier. I will copy it to the clipboard and I'll paste it in this code location. If the user clicks the Yes button on the confirmation dialog, I'll activate this bit of code that goes to the delete page.

I'll test this code in an external browser. I'll save my changes and then click the Run button on the toolbar. I will click the delete link and click Yes and take a look at the URL in the browser, delete.cfm?photographeri =, and then the primary key of the selected record. So, I'm on the right track. I need to create the delete page, which will delete the data from the backend database. I will close the external browser and return to ColdFusion Builder.

I will go to the Navigator view, to the photographer's folder of the Photo Gallery application. I will right-click on it and choose New > ColdFusion Page and I'll name my new file delete.cfm. The user will never see this page. It will be purely a backend page that's called, executes its functionality and then returns the user back to the list page. So, it doesn't need any HTML. I'll select all of the default code by pressing Ctrl+A on Windows or Command+A on Mac and then pressing Delete or Backspace.

Then I will create a pair of cfscript tags. Here are the tasks I need to accomplish. First, I need to discover whether the variable photographerid was passed to this page. I will use an if command. If and then, under pair of parentheses, isDefined and then I will pass in the name of the variable as a string that I'm looking for. url.photographerid. Then within a pair of curly braces, if I received that variable, I will retrieve the matching data object from the backend database, using this code, photographer = entityLoadByPK, and I'll pass in the name of the entity I am looking for, Photographer, and the primary key that I received in the URL variable url.photographerid and I will make sure to add a semicolon at the end of the line.

I have my photographer object in memory and I can call another ORM method, this one named entityDelete, which expects an ORM object. I will call entityDelete and pass in the photographer variable. And once again, terminate the statement with a semicolon. At the end of the if clause, below the closing brace, I will use ColdFusion 9's new location method and I'll pass in the name of the page I want the user to go to index.cfm.

When this page is loaded into the browser, if the photographerid variable is passed in the URL scope, the matching data will be deleted from the database table. If that variable is not passed in, then these two lines of code will be ignored and either way the location function will send user back to the beginning page index.cfm. I will save my changes and I'll go back to the list page, index.cfm, and now I'm ready to test the whole workflow. I'll save any changes I need to save and then I'll load the page into the browser.

I will click the delete link for one of my new records. I will delete Joe Jones. The first time I will click No and confirm that nothing bad happens. Because I clicked No, I canceled the operation. I will click the delete link again and this time I will click Yes and the browser navigates to the delete page invisibly, deletes the data and then immediately navigates back to the list page and I can see that the data was successfully deleted. I will click the delete link for John Smith and click Yes again, and I can see once again that the data is gone.

So, those are all of the pieces of a good delete operation. Make sure that you give the user an opportunity to cancel the operation. If you simply delete data as result of a single click, it's too easy to make a mistake for the user. You allow them to confirm or cancel the operation and then use a separate page to actually do the delete operation.

Find answers to the most frequently asked questions about ColdFusion 9 Essential Training .

Expand all | Collapse all
please wait ...
Q: While trying to build a dynamic site as instructed in the ColdFusion 9 Essential Training title, an error occurred when setting up the Date & Services > Data Sources page as shown in the "Defining a data source in ColdFusion Administrator" movie:

Connection verification failed for data source: dw_bookstore. com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up. 

Also, attempts to connect to the database using phpMyAdmin were not successful. Is there a fix to this problem?
A: If the connection to phpMyAdmin is not working, starting over with the installation of MySQL is the best bet. Uninstall WampServer, then reinstall and set up the database again. If that software is not working, the connection to the database from will not be possible from ColdFusion.
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.

Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now Already a member? Log in

* Estimated file size

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.

Mark all as unwatched Cancel


You have completed ColdFusion 9 Essential Training.

Return to your organization's learning portal to continue training, or close this page.

Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member ?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any page and choose Site preferences from the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Thanks for signing up.

We’ll send you a confirmation email shortly.

Sign up and receive emails about and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from

Sign up and receive emails about and our online training library:

Here’s our privacy policy with more details about how we handle your information.

submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.