Mastering Dreamweaver MX Databases
|
|
As we mentioned, Dreamweaver MX works well with ColdFusion. Using the forms and panels in Dreamweaver MX, you can include a large part of the ColdFusion command set just by clicking your mouse. When you're working with a ColdFusion page, Dreamweaver MX places three ColdFusion- specific tabs across the Insert bar: CFML Basic, CFML Flow, and CFML Advanced. These three tabs provide quick access to the major components and tags within ColdFusion, along with pop-up windows to guide you in creating the tag. Let's take a look at a few of those.
The CFML Basic Tab
Figure 11.15 shows the CFML Basic tab and its components. These items are some of the most commonly used ColdFusion tags and components. Dreamweaver MX provides an easy way to apply these to your code-simply click the button to display a window containing text fields and settings appropriate for the tag.
The Server Variables Button
ColdFusion, naturally, can use server variables just like ASP. In Dreamweaver MX, you can quickly access many of these server variables by clicking the Server Variables button to open the Server Variable dialog box, which will be similar to that in Figure 11.16.
The CFQuery Button
You don't have to remember the syntax of the many-optioned <cfquery> tag when you click the CFQuery button on the Insert bar. Figure 11.17 shows how Dreamweaver MX pops up a window to guide you through the options.
The Comment Button
Clicking the Comment button throws a comment into your code. That is, it adds the opening and closing brackets for a comment. And, if you highlight the text that you want to turn into a comment and click the Comment button, Dreamweaver MX simply wraps the text with the comment tags for you, as you can see in Figure 11.18. This is a great way to temporarily block out chunks of code when you're debugging an application.
The Surround With ## Button
Just like the Comment button, the Surround With ## button wraps the selected text in pound signs. Many times, while cranking out code, you may forget to add the pound signs around your variables. You can simply highlight your variables and click the Surround With ## button to place the pound signs around them.
The CFML Flow Tab
The CFML Flow tab (see Figure 11.19) contains buttons for quick access to constructs that affect the logic flow of your application. Many of these, such as CFTry and CFCatch, require more explanation than this chapter allows. But let's explore a couple of the options so you can get the feel of what's on this toolbar.
The CFLock Button
Clicking the CFLock button effectively prevents any other user from executing code that exists within the <cflock></cflock> tags. This helps you maintain integrity in your application when you're updating variables that can be shared across the application or even sessions. Figure 11.20 shows a sample CFLock window. You give the lock a name, set a timeout value so that the lock frees up if it can't lock the code within the time specified, and you set the type and scope of the lock. The code this generates looks like the following:
<cflock name="UpdateApplicationVariable" timeout="2" throwontimeout="no" type="exclusive" scope="application"> </cflock>
You place variable setting code between the opening and closing tags to make sure that only the current process can update a variable at a given moment.
The CFIf, CFElse, and CFElseIf Buttons
Clicking any of these three buttons simply places the opening tag in your code. Clicking one of these buttons doesn't open a dialog box, but it does save typing. For example, if you click the CFIf button, Dreamweaver MX inserts <cfif></cfif> in your code and places the cursor at the space character within the opening <cfif> tag so you can immediately type the IF condition for which you're testing.
The CFLoop Button
Clicking the CFLoop is the same as using a For-Next or Do-While loop in other languages; however, it's more powerful and more flexible. You can use CFLoop to create five types of loops, as you can see in Figure 11.21. The Index loop is like a For-Next loop. The Conditional loop is like a Do-While loop. The next three loop through a Query, a List, or a Collection, executing the loop once for every item in the type. This saves you from having to calculate the number of items in a construct and then looping from 1 to that number. Naturally, Dreamweaver MX adjusts the fields in the CFLoop dialog box to ask for the appropriate information.
The CFML Advanced Tab
The CFML Advanced tab, shown in Figure 11.22, gives you access to more advanced features of ColdFusion's code base. Although clicking these buttons gives you access to the most common features of the item represented, you'll want to spend some time with the documentation, help files, or online forums to learn the power of these items. We're going to show a couple, however, to get you started.
The CFCookie Button
To set cookies, you can click the CFCookie button. You can actually set six options for a cookie tag, and Dreamweaver MX makes it easy for you to use those options, as you can see in Figure 11.23. Just enter the values you want in the appropriate box and click OK, and you have instant cookie code.
The CFApplication Button
The <cfapplication> tag is a special tag that typically goes in the Application.cfm file. It sets values for the application name, session timeout values, application timeout values, and so forth. (See Figure 11.24.) (Remember, your application can set these values, but the ColdFusion Administrator settings always override the application if they should disagree.) The settings we entered create code similar to the following:
<cfapplication name="MyApplication" clientmanagement="yes" sessionmanagement="no" setclientcookies="no" setdomaincookies="no" sessiontimeout="120" clientstorage="ClientVar">
If you're serious about using ColdFusion, explore the vast resources Macromedia has devoted to ColdFusion on their website. You'll find tons of documentation, hints, sample code, and online forums where you can ask questions and share experiences with other ColdFusion users.
You might also want to check out Mastering ColdFusion MX or ColdFusion MX Developer's Handbook, both from Sybex, or any of Ben Forta's books. Some favorite online sources of ours are Ben Forta's site at www.forta.com and Webmonkey at www.webmonkey.com.
|
|