Introduction to ColdFusion
In early 2001, Macromedia acquired a company by the name of Allaire. With the acquisition, Macromedia also acquired a key server-side technology component named ColdFusion and the tool used to develop ColdFusion pages, ColdFusion Studio (now directly integrated into Dreamweaver). Described as a rapid server-side scripting technology for creating web applications, ColdFusion uses a language called ColdFusion Markup Language (CFML) to interact with databases and dynamically created pages. CFML tags are embedded directly int225, and each command has a start tag and an end tag similar t225. Each ColdFusion application is a set of pages with CFML commands in them. Developers can use the built-in functions, create their own, or integrate COM, C++, or Java components into their code.Now an essential technology in the Macromedia web development line, ColdFusion relies on the ColdFusion Application Server. After it's installed, the application server functions similar to the .NET Framework discussed in the previous sections) in that it closely monitors and manages ColdFusion web applications. Furthermore, you can use the ColdFusion Administrator, available as a standalone web application, to manage everything from data sources, memory usage, mail server properties, caching, error logs, and more.
Installing ColdFusion
Although ColdFusion isn't as straightforward an installation as ASP and ASP.NET are, it's still a fairly simply install. In fact, ColdFusion is available on the Macromedia Studio CD-ROM, Dreamweaver CD-ROM, or as a free 45-day trial from the Macromedia Website at http://www.macromedia.com/software/coldfusion. The following steps assume that you're using either the Studio or Dreamweaver CD-ROM to install ColdFusion:
Because ColdFusion is an application server, it runs as both a Windows service and a process. You can stop, start, or configure this service by clicking the Start button and then selecting Settings, Control Panel, Administrative Tools, Services. You can then select Macromedia ColdFusion MX Application Server and right-click the option to access specific commands such as Start, Stop, and Restart.
The ColdFusion Administrator
After you've installed ColdFusion, you can set properties for the application server by using the ColdFusion Administrator. The ColdFusion Administrator allows you to perform administrative tasks for the application server, such as adding and configuring a data source, scheduling application page execution, configuring a RDS password, setting security settings, and more.You can access the ColdFusion Administrator by entering the URL http://localhost/CFIDE/Administrator. The first time you launch the administrator, you are asked to configure RDS access.TIPRemote Development Services (RDS) lets you access a remote ColdFusion MX server using HTTP. Using RDS, Dreamweaver users can securely access remote files and data sources, build SQL queries from these data sources, and debug CFML code. It's generally a good idea to configure RDS on development machines and to disable it on production machines.Because we'll be using RDS for the ColdFusion examples in the book, set the password now and click Next. The Administrator then runs through its final configuration process, installing ODBC drivers, sample applications, and more. When the configuration ends, you are redirected to the login screen. From here on out, whenever you access the administrator, you are taken directly to this page.To log into the Administrator, type the password you entered during the ColdFusion installation process (step 11 in the previous section). When you are logged in, you will see the myriad of modifiable settings similar to Figure 22.13.
Figure 22.13. The ColdFusion Administrator allows you to configure various aspects of the ColdFusion Application Server.
[View full size image]

- Server Settings :
Set various generic properties of the application server including caching, client variables, memory variables, the default mail server, dynamic charting, and more. - Data & Services :
Access options in this category to configure data sources, web services, and more. - Debugging & Logging :
Choose options in this category to set various debugging options for your code. Furthermore, you can set how and where ColdFusion logs errors, and more. - Extensions :
Use options in this category to set how ColdFusion interacts with Java applets, CORBA connectors, and more. - Security :
Set various security-related settings by accessing options in this category. Options include setting the administrator password and the RDS password, as well as specifying security information for individual data sources, ColdFusion tags, ColdFusion functions, files and directories, and servers/ports.
Creating a Simple ColdFusion Page
Now that you've had a formal introduction to ColdFusion and the ColdFusion Administrator, let's walk through the process of creating a simple ColdFusion page. Not only will this process help familiarize you with the technology, it also gives you a basic understanding of how IIS works in conjunction with ColdFusion to process ColdFusion markup pages. To create a simple ColdFusion page, follow these steps:
1. | Create a new folder within C:\Inetpub\wwwroot called DorknozzleCFM. |
2. | Open Notepad (we'll get to Dreamweaver in a few sections). |
3. | In the document, add the following code:
|
4. | Save your work as sample.cfm in the new folder named C:\Inetpub\wwwroot\DorknozzleCFM. |
TIPIf you plan on trying out numerous server-side technologies, it's beneficial to create the folder with the Dorknozzle name followed by the three-letter server-side technology you plan to use. This convention prevents you from continuously having to redefine the site for every server-side technology.To test your work, open the browser and type the URL http://localhost/DorknozzleCFM/sample.cfm in the address bar. As you can see from Figure 22.14, two lines of text appear on the page.
Figure 22.14. Two lines of text appear on the page. Some of this text is plain text parsed from <h1> tags in the browser. The date, however, is dynamically generated.

In this case, we use a <cfoutput> tag to dynamically display the text Hello it is in a <h1> HTML tag. IIS, recognizing that this code render block exists, intercepts the request and calls for help from ColdFusion (processed using the jrun.dll located in the C:\CFusionMX\runtime\lib\wsconfig\1\folder by default). ColdFusion processes the request and interprets the <cfoutput> tag to mean "Output today's date using the standard MM/DD/YY format" onto the page. This response is sent back to IIS and ultimately back to the browser formatted using the <h1> tag. Although the process may seem complex, it happens so fast that a user rarely knows that a dynamic page is even being used.See how easy that was? In this example, we manually coded ColdFusion markup. The beauty in using Dreamweaver is that you don't have to code at all. Dreamweaver writes all the necessary markup for you. More on this later. For now, let's focus on getting our project configured so that we can use ColdFusion to create dynamic Dorknozzle pages.
<h1>Hello it is: <cfoutput>#DateFormat(Now(), "MM/DD/YY")#</cfoutput></h1>
Configuring Dorknozzle to Run Under ColdFusion
Up to this point, we've been working primarily from C:\Dorknozzle\<chapterfolder >. From now on, we'll work from C:\Inetpub\wwwroot\DorknozzleCFM (assuming that you're using ColdFusion). Because this is the case, we need to reconfigure the site definition to point to the new folder we've created. Furthermore, we need to configure the Testing Server category in the Site Definition window to provide Dreamweaver with information specific to the technology you plan on using for the defined site. To configure Dorknozzle to run under ColdFusion, follow these steps:
1. | If you haven't downloaded the files for this chapter, do so now. Open the folder for Chapter 22, copy the contents out of the folder, and paste them into the newly created DorknozzleCFM folder in C:\Inetpub\wwwroot. Now you have all the assets, images, library items, and an index.cfm page you need to get started. After you've copied the files over, you should have Assets, Images, and Library folders including a CSS file, index.cfm page, and the sample.cfm page you've been working with to this point. |
2. | Open Dreamweaver if you haven't already done so and choose the Manage Sites option from the Site menu. |
3. | Select the existing Dorknozzle site from the list and click Edit. The Site Definition for Dorknozzle dialog appears. |
4. | In the Site Name text box, rename the site from Dorknozzle to DorknozzleCFM. |
5. | Now browse to the C:\Inetpub\wwwroot\DorknozzleCFM\ folder in the Local Root folder category. Leave everything else as is. |
6. | Now switch to the Testing Server category. |
7. | Select the ColdFusion option from the Server model category. |
8. | Choose the Local/Network option from the Access menu. New properties become available that allow you to configure the location of the remote folder as well as the URL prefix for the remote folder.NOTEOther options are available in the Access menu for defining remote access to the testing server. Similar to what happens when you select the Remote Info category, when you select FTP and WebDAV, you're presented with options for configuring the Host, Host directory, Login, Password, and so on. An additional option that appears in the Access menu is RDS. Remote Development Services (RDS) lets you access a remote ColdFusion MX server using HTTP. Using RDS, Dreamweaver users can securely access remote files and data sources, build SQL queries from these data sources, and debug CFML code. |
9. | Browse to the same C:\Inetpub\wwwroot\DorknozzleCFM\ path in the Remote Folder text box. In most cases, this value is pre-populated when you select the Local/Network option from the Access menu.NOTEWhen working with web applications, the ideal scenario is that you'll have a development machine, a production machine (server), and a testing server. Realistically, not everyone can afford another server just for testing purposes. Most of us will rely on the development machine to function as a testing server as well. For this reason, we'll simply define our testing server as the local development machine. If you do have a dedicated testing server, you'd probably use the RDS option instead. |
10. | Enter the URL to our Dorknozzle site. This value should read http://localhost/dorknozzlecfm/ . Remember that localhost, like every other domain name (such as yahoo.com and google.com) is a URL accessible from a browser. Rather than accessing the site from a server miles away, the browser knows that localhost (and the IP address 127.0.0.1 associated with it) is the URL for the local instance of IIS (your computer). Because this is the case, it doesn't have to look too far for your files. |
11. | Click OK to close the Site Definition for DorknozzleCFM window. |
12. | Click Done to close the Manage Sites dialog. |
You're now ready to begin building dynamic Dorknozzle pages using Dreamweaver and ColdFusion!
Using ColdFusion in Dreamweaver
Depending on the server technology you decide to use, features exposed in Dreamweaver's interface change. For the most part, however, you can bank on the fact that the following features are always available when working with any server-side technology, including ColdFusion:
- The Insert Bar :
A visual representation of objects available in the Insert menu, the Application category in the Insert bar, allows you to visually insert various types of dynamic objects onto your page. - The Insert menu :
Use the Application Objects and ColdFusion Objects submenus in the Insert menu to insert both generic application objects as well as ColdFusion-specific objects. - The Application Panel :
Divided into four tabs (Databases, Bindings, Server Behaviors, and Components), the Application panel provides the means for connecting to and accessing database data, binding that data to elements on the page, accessing various application objects, and consuming Web services or ColdFusion Components (CFC). When working with dynamic pages in Dreamweaver, you should always have this panel open. - The Tag Chooser :
If you want to make fine-tuned changes in your ColdFusion markup, choose specific elements from the Tag Chooser. Available by choosing the Tag option from the Insert menu, you can choose an option from the Tag Chooser to open the Properties dialog for the particular tag, allowing you to further customize attributes of the tag. - The Reference Panel :
If you ever need help regarding the various ColdFusion objects, application objects, or tags, you can reference them from the Reference panel available, by choosing the Reference option from the Window menu.
Earlier, I mentioned that most of the dynamic functionality built into Dreamweaver is the same regardless of the server-side technology you decide to use. This becomes obvious with the Application Objects submenu in the Insert menu and the Application category in the Insert bar. The objects listed in these menus expose generic functionality that remains consistent regardless of server-side technology. What does change is the option below the Application Objects option in the Insert menu. This option (which varies from ASP Object, ASP.NET Objects, ColdFusion Objects, and PHP Objects, depending on which server-side technology you decide to use), displays specific content accordingly.