Home arrow ColdFusion arrow Page 4 - Introduction to ColdFusion Markup Language

Introduction to ColdFusion Markup Language

If you want to get a good start on learning ColdFusion, look no further. This article covers a whole bunch of CFML tags and some basic functions. It is the first of two parts, and excerpted from chapter three of the book ColdFusion Web Development with Dreamweaver MX 2004, written by Jen and Peter deHaan et al. (Apress; ISBN: 1590592379).

Author Info:
By: Apress Publishing
Rating: 5 stars5 stars5 stars5 stars5 stars / 50
January 19, 2006
  1. · Introduction to ColdFusion Markup Language
  2. · Tags Used in CFML
  3. · The Application.cfm File
  4. · Understanding Common ColdFusion Tags
  5. · The cfif tag
  6. · The cfswitch tag
  7. · The cflocation tag

print this article

Introduction to ColdFusion Markup Language - Understanding Common ColdFusion Tags
(Page 4 of 7 )

In this section we look at some more common CFML tags that you'll use in everyday ColdFusion development. The functions these tags have range from setting variables and interacting with the operating system on the server, to sending e-mails to users or administrators.


The<cfparam>tag is similar to the<cfset>tag used in the previous section, but with one important difference:<cfparam>will set the variable only if it does not yet exist. This is useful when you want to set default values or need to make sure that a variable exists before trying to use it.

The syntax is as follows:

<cfparam name="Url.date" default="#Now()#">

What this snippet does is check to see if a URL variable named "date" exists; if it does, then<cfparam>does nothing. If the variable is not found, then it is created and given a value equal to the current date and time. This way, you are not overwriting variables if they are already defined, and you can always be sure that variables exist and have values. Note that if the value of the "name" attribute (the variable name) does not have a prefix, the server will assume you are setting avariable in the local "variables" scope.

With the simple addition of a type attribute, this tag can also check to make sure that a variable is of a certain data type. Here's an example:

<cfparam name="Url.date" default="#Now()#" type="date">

In this case, if the value of the#Url.date#variable is not a valid date, ColdFusion will throw an error, as shown in Figure 3-2.

Figure 3-2.   An error is thrown if the data type specified in the<cfparam>type attribute is not the same as the data type of the variable being set.

We cover error handling in more detail in Chapter 8.

If you provide only a name and type attribute for the<cfparam>tag, ColdFusion makes sure that the variable already exists and is of the correct data type. If either of these conditions fail, ColdFusion will throw an error.

We can view the supported types in Dreamweaver MX 2004. Click on the CFML Basic tab on the Insert bar in Dreamweaver, then click on the cfparam button, which looks like an exclamation mark and is ninth from the left, as shown in Figure 3-3.

Figure 3-3.   The Dreamweaver MX 2004 Insert bar, with the basic CFML functions shown and the cfparam button illustrated

When you click the cfparam button, you are presented with the dialog box in Figure 3-4, in which you can set the attributes we looked at previously.

Figure 3-4.   The Dreamweaver MX 2004 cfparam Tag Editor

blog comments powered by Disqus

- Adobe ColdFusion Just Got More RAD
- How to Access a SQL Anywhere Database with C...
- CFXML: Probing XMLDOM in ColdFusion
- Creating a Web Service with ColdFusion: the ...
- CFAjax: What it is and How to Use it
- Querying SQL 2000 Server from ColdFusion
- Introduction to ColdFusion Markup Language, ...
- Introduction to ColdFusion Markup Language
- Databases and Dreamweaver MX 2004, concluded
- Databases and Dreamweaver MX 2004
- Welcome to Coldfusion MX 6.1, concluded
- Welcome to Coldfusion MX 6.1
- What You Must Know About ColdFusion Flow-Con...
- What You Must Know About Operators in ColdFu...
- Everything You Must Know About ColdFusion Va...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials