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.
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'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 .
Here are the FAQs that matched your search "" :
Sorry, there are no matches for your search "" —to search again, type in another word or phrase and click search.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
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.