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.
ColdFusion makes it very easy to create a single page that's used for both inserting and updating data. I am going to repurpose the edit.cfm file and turn it from a form that only inserts data right now to one that can be used for both inserting and updating. I'll start in the list page, index.cfm. That's showing me a list of my photographers, and I'll add another column with hyperlinks that the user can click to edit an existing photographer record.
In the source code I'll go first to the Header row and I'll add a new pair of th's. I am not going to put any text in between these tags, because I don't need to display anything at the top of the column. Then I'll go to the line of code that shows the link for the photo list. I'll click into that line of code and then clone it, pressing Ctrl+Alt+Down on Windows or Command+Alt+Down on Mac, and I'll make some changes to that code. In the second link, I'll set the href to point to edit.cfm and I'll change the text from Photos to Edit.
Now, when I run the page in the browser, I see a hyperlink for each photographer and when I click that link, I'll go to the form page and the next part of the job is to fill in the form with the existing data from the photographer record that the user selected. I'll go back to Source and I'll go to the edit.cfm file. I am going to add a little bit more conditional logic to the page and detect whether I received that URL variable, photographerid.
After the existing if clause, I'll add else if, and then in a pair of parentheses isDefined and I'll look for the variable photographerid and I'll add a pair of curly braces right after the else if clause. So now, I have one section for when the page is submitted from the form and a second conditional section that will be executed if the user gets to this page by clicking on one of the edit links in the list page. So, I have my drill down system to get from one page to another.
In this page, I'll retrieve the one and only photographer data row that the user selected. I'll do that with a method called entityLoadByPK. This is a different version of the entityLoad method that we've used before. The entityLoad method on its own returns an array of photographer objects. When you know you need only one photographer object though, you can use entityLoadByPK. You'll pass in the primary key value that identifies the object and instead of an array you'll get back just that object.
The code will look like this. Photographer = entityLoadByPK and then I'll pass in two arguments. The name of the orm entity I want, photographer, and remember that that must be case sensitive and exact, and then the primary key value, which is provided in url.photographerid. So now, let's test the drill-down architecture. I'll place the cursor after the cfscript section and put in a little bit of temporary code for debugging.
cfif isDefined photographer and I am looking for the photographer variable here and then I'll put in a cfdump tag with a var attribute of photographer. And then after the cfdump I'll put in a cfabort. Again, this is a temporary debugging code so I can see what happens when the page is loaded from the list page. I'll save the changes to the form page and go to index.cfm. I'll run that page in the browser and click on the first link and I'll see that I've successfully retrieved the one and only photographer from the table that was requested.
I'll go back to Source and run it in the browser again, and click on another link. And once again, I am confirming that I am getting back the data that's requested. So now, you've retrieved the data based on the drill-down hyperlink and in the next video, I'll show you how to fill in the form controls from the existing data.
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.