Viewers: in countries Watching now:
In ColdFusion 9 New Features, author and developer Dan Short has gathered together the important updates and improvements in this dynamic web application. Dan showcases the new ColdFusion Builder application throughout the course, using it to work through the new language and CFScript enhancements in this release. He shows how to use the new Server Manager to compare servers and create server groups, as well as monitor server health through notifications. He also explains the new integration with Office applications, building Excel, Word, and even PowerPoint files on the fly from ColdFusion. Finally, he covers the important new Object Relational Mapping feature and how to use the built-in Flash Player. Exercise files accompany this course.
A longtime complaint of ColdFusion users who prefer to code using CFScript is that they couldn't do everything they need to do without though jumping out of a CFScript block to use a tag which didn't have a CFScript equivalent. ColdFusion 9 gets us most of the way there by adding a bunch of new functions to the language by creating proxy objects for complex tags such as cfquery and cfmail. In this video, I will demonstrate a few of the new functions that have been added, show you how to find the implementations of ColdFusion9's Proxy Objects, and how do you cfquery and cfmail inside of CFScript and the first few functions we'll take a look at are system-level functions, such as Throw, cfdump, cflock, location and cftrace.
These all now have their own functions and what would normally be attributes on the tag have now become arguments to a function. So the first thing I'll do is demonstrate the writedump function. In your Chapter3 folder, open up cfscript.cfm and I just have a blank CFScript block that we are trying to use for our testing inside of this video. So I am going to create a new object or rather a new structure and instead of using a cfdump, we'll do writedump and I'll say var = Person, Label ="My Person Structure" and we'll preview the file.
And here we see a dump just like we would if we used cfdump. While that's not terribly exciting from a demonstration point of view, this makes it a whole lot easier to debug your code inside of a CFScript block. Normally you would have to close the CFScript block, put your dump in and then open it so that you can continue processing your code. So let's take a look at the next batch of functions. This group of tags that have bodies, such as cflock, cfthread, and cftransaction. For these you will call the function and provide braces to show the start and stop of the action.
So I will demonstrate the lock function, the CFScript equivalent to cflock. Let's comment at our previous code and now I'll use the new lock function. We will specify a timeout at ten seconds and tell it which scope we want to lock, in this case the Application scope. Now you can see I am also getting code hints in CF Builder to name the lock, set my throwontimeout, and then specify a type readOnly or exclusive. I will just leave things as they are for now.
Open my closing braces, and it will close them automatically for me. And then inside here I can do whatever I want inside that lock. And that's all there is to using the tags with bodies. The other functions in this group, thread and transaction, have sibling functions that you'll use within the parent function. So inside the transaction function, you can use transactionCommit and transactionRollback, instead of calling the cftransaction tag with a separate action. The next group of tags is tags without bodies.
In this case, we're calling a function and specifying arguments but we don't have a body to wrap code in like we do with the previous group. So in this case, I will show you how to use the param function versus cfparam. Let's once again comment out our code. So we are going to create a new param function and we will say that this parameter is going to be numeric and FORM.id and we'll set it's default value to 2. Just to make sure this works, we'll go ahead and writedump our FORM scope, and preview our file.
And here you can see it's defined id with the default value of 2. Our last batch of functions aren't really functions. Instead they are complex objects, which are used to replace the functionality of cfquery, cfmail, cfftp and other tags that have more complex interaction. So to show you how to work these, I am first going to show you where you can find them in ColdFusion's Component browser. So in the browser, we will go to our ColdFusion Administrator, CFIDE directory and in the componentutils directory, we will go to componentdoc.cfm.
On the left-hand side, scroll down until you find com.adobe.coldfusion. Click that link and down here, you'll see each of the new objects that are used to replace an existing ColdFusion tag. If I click on query, we can see we have a large number of methods we can use. You can use this Component browser to figure out how to use each of the new proxy objects inside ColdFusion 9. For now I am going to show you how to use the query object.
So let's once again comment out our code and I will start by creating a new query object. So I will say myQuery = new Query(). Now that I have that object, I can start setting properties about the query that I want to run. First we will do myQuery.setDatasource and tell it that we want to use the cfartgallery data source. Next I will set the query that I want to run. So we will setSQL(SELECT * FROM Artists).
And now I can execute my query and assign the result to a variable. So, Artists = myQuery.Execute. I writedump Artists. You can see I get a complex result object back. The result object has a result property, which contains my query. It also has some prefix information that gives me the SQL that was executed, the record count and I have a number of methods that I can use on that object.
The most important one is GetResult. So we will go back to the source code and I will dump Artists.getResult. And that gives me back a regular query, just as I would receive if I use the cfquery tag. Now I can do more with the CFQuery, for example, using query params. If I wanted to select only a specific artist, I can do SELECT * FROM Artists where ArtistID = the :ArtistID keyword.
I can then set a parameter for that particular keyword. I will use myQuery.addParam. I am going to specify the artistID parameter, give it a value, and a cfsqltype for validation purposes. Now if I run this code again, I will get a single record back from the database. Cfmail works the same. Let's comment out the query and I will show you how to use the cfmail object.
Let's do myMail = New Mail(). But instead of setting each of these values individually, I am going to use the setAttributes function that's available to all of these objects. So myMail.setAttributes and then I will provide a structure that has all of the configuration for this particular e-mail I want to send. We will say to = firstname.lastname@example.org from email@example.com, subject = "Testing new CFScript objects".
I will set the body of the e-mail and then all I have to do to send my e-mail is myMail.send. So as you can see with the addition of new functions and objects available to CFScript, you can get one step closer to building an entire ColdFusion application with nothing but CFScript.
There are currently no FAQs about ColdFusion 9 New Features.
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.