ColdFusion
  Home arrow ColdFusion arrow Page 4 - Introduction to ColdFusion Markup Language
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Moblin 
JMSL Numerical Library 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
COLDFUSION

Introduction to ColdFusion Markup Language
By: Apress Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 8
    2006-01-19

    Table of Contents:
  • Introduction to ColdFusion Markup Language
  • Tags Used in CFML
  • The Application.cfm File
  • Understanding Common ColdFusion Tags
  • The cfif tag
  • The cfswitch tag
  • The cflocation tag

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    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.

    <cfparam>

    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

    More ColdFusion Articles
    More By Apress Publishing


       · This article is an excerpt from the book "ColdFusion Web Development with...
     

    Buy this book now. This article is 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). Check it out today at your favorite bookstore. Buy this book now.

    COLDFUSION ARTICLES

    - 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...
    - My First Application on ColdFusion MX Server







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway