Macromedia COLFUSION MX 7 User Manual

COLDFUSION®MX 7
ColdFusion MX Developer’s Guide
Trademarks
1 Step RoboPDF, ActiveEdit, ActiveTest, Authorware, Blue Sky Software, Blue Sky, Breeze, Breezo, Captivate, Central, ColdFusion, Contribute, Database Explorer, Director, Dreamweaver, Fireworks, Flash, FlashCast, FlashHelp, Flash Lite, FlashPaper, Flex, Flex Builder, Fontographer, FreeHand, Generator, HomeSite, JRun, MacRecorder, Macromedia, MXML, RoboEngine, RoboHelp, RoboInfo, RoboPDF, Roundtrip, Roundtrip HTML, Shockwave, SoundEdit, Studio MX, UltraDev, and WebHelp are either registered trademarks or trademarks of Macromedia, Inc. and may be registered in the United States or in other jurisdictions including internationally. Other product names, logos, designs, titles, words, or phrases mentioned within this publication may be trademarks, service marks, or trade names of Macromedia, Inc. or other entities and may be registered in certain jurisdictions including internationally.
This product includes code licensed from RSA Data Security.
Third-Party Information
This guide contains links to third-party websites that are not under the control of Macromedia, and Macromedia is not responsible for the content on any linked site. If you access a third-party website mentioned in this guide, then you do so at your own risk. Macromedia provides these links only as a convenience, and the inclusion of the link does not imply that Macromedia endorses or accepts any responsibility for the content on those third-party sites.
Copyright © 1999–2005 Macromedia, Inc. All rights reserved. U.S. Patents Pending. This manual may not be copied, photocopied, reproduced, translated, or converted to any electronic or machine-readable form in whole or in part without written approval from Macromedia, Inc. Notwithstanding the foregoing, the owner or authorized user of a valid copy of the software with which this manual was provided may print out one copy of this manual from an electronic version of this manual for the sole purpose of such owner or authorized user learning to use such software, provided that no part of this manual may be printed out, reproduced, distributed, resold, or transmitted for any other purposes, including, without limitation, commercial purposes, such as selling copies of this documentation or providing paid-for support services. Part Number ZCF70M500
Acknowledgments
Project Management: Randy Nielsen
Writing: Hal Lichtin, Randy Nielsen, Robert Berry, Chris Bedford, Anne Sandstrom
Editing: Linda Adler, Noreen Maher
Production Management: Patrice O’Neill
Media Design and Production: John Francis, Adam Barnett
Special thanks to Sawako Gensure, Seungmin Lee, Takashi Koto, Nozomi Kugita, Masayo Noda, Hiroshi Okugawa, Bowne Global Solutions
First Edition: January 2005 Macromedia, Inc.
600 Townsend St. San Francisco, CA 94103

CONTENTS

INTRODUCTION: About ColdFusion MX Documentation . . . . . . . . . . . . . . . . . . 13
Using this manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
CHAPTER 1: Introducing ColdFusion MX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
About Internet applications and web application servers . . . . . . . . . . . . . . . . . . . . 19
About ColdFusion MX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
About J2EE and the ColdFusion architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
PART I: The CFML Programming Language
CHAPTER 2: Elements of CFML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
CFML Basics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Tags. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
ColdFusion components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Flow control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Character case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Special characters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Reserved words . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
CFScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
CHAPTER 3: Using ColdFusion Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Creating variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Variable characteristics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Strings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Using periods in variable references . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Data type conversion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
3
About scopes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Ensuring variable existence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Validating data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Passing variables to custom tags and UDFs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
CHAPTER 4: Using Expressions and Number Signs . . . . . . . . . . . . . . . . . . . . . . 75
Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Using number signs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Dynamic expressions and dynamic variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
CHAPTER 5: Using Arrays and Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
About arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Basic array techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
Populating arrays with data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Array functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
About structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Creating and using structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
Structure examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
Structure functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
CHAPTER 6: Extending ColdFusion Pages with CFML Scripting . . . . . . . . . . . 123
About CFScript. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
The CFScript language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
Using CFScript statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
Handling exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
CFScript example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
CHAPTER 7: Using Regular Expressions in Functions . . . . . . . . . . . . . . . . . . . . 141
About regular expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
Regular expression syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
Using backreferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
Returning matched subexpressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
Regular expression examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
Types of regular expression technologies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
PART II: Building Blocks of ColdFusion Applications
CHAPTER 8: Creating ColdFusion Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
About CFML elements you create . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
Including pages with the cfinclude tag. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
About user-defined functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
Using ColdFusion components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
Using custom CFML tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
Using CFX tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
Selecting among ColdFusion code reuse methods . . . . . . . . . . . . . . . . . . . . . . . . 169
4 Contents
CHAPTER 9: Writing and Calling User-Defined Functions. . . . . . . . . . . . . . . . . 171
About user-defined functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
Creating user-defined functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
Calling user-defined functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
Working with arguments and variables in functions . . . . . . . . . . . . . . . . . . . . . . 178
Handling errors in UDFs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
A user-defined function example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
Using UDFs effectively . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
CHAPTER 10: Building and Using ColdFusion Components . . . . . . . . . . . . . . . 201
About ColdFusion components. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
Creating ColdFusion components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
Using ColdFusion components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
Passing parameters to methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
CFC variables and scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
Using CFCs effectively . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
ColdFusion component example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
CHAPTER 11: Creating and Using Custom CFML Tags . . . . . . . . . . . . . . . . . . . 241
Creating custom tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
Passing data to custom tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
Managing custom tags. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
Executing custom tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
Nesting custom tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
CHAPTER 12: Building Custom CFXAPI Tags . . . . . . . . . . . . . . . . . . . . . . . . . . 259
What are CFX tags?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
Before you begin developing CFX tags in Java. . . . . . . . . . . . . . . . . . . . . . . . . . . 260
Writing a Java CFX tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
ZipBrowser example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264
Approaches to debugging Java CFX tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
Developing CFX tags in C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
PART III: Developing CFML Applications
CHAPTER 13: Designing and Optimizing a ColdFusion Application . . . . . . . . . 275
About applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
Elements of a ColdFusion application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276
Structuring an application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
Defining the application and its event handlers in Application.cfc. . . . . . . . . . . . 282
Migrating from Application.cfm to Application.cfc. . . . . . . . . . . . . . . . . . . . . . . 294
Using an Application.cfm page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
Optimizing ColdFusion applications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
Contents 5
CHAPTER 14: Handling Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
About error handling in ColdFusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
Understanding errors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308
Error messages and the standard error format . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
Determining error-handling strategies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
Specifying custom error messages with the cferror tag . . . . . . . . . . . . . . . . . . . . . 317
Logging errors with the cflog tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321
Handling runtime exceptions with ColdFusion tags . . . . . . . . . . . . . . . . . . . . . . 322
CHAPTER 15: Using Persistent Data and Locking . . . . . . . . . . . . . . . . . . . . . . . 339
About persistent scope variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340
Managing the client state. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342
Configuring and using client variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
Configuring and using session variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
Configuring and using application variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
Using server variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359
Locking code with cflock. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
Examples of cflock. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368
CHAPTER 16: Securing Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373
ColdFusion security features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374
About resource and sandbox security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375
About user security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376
Using ColdFusion security tags and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 381
Security scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 386
Implementing user security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 388
CHAPTER 17: Developing Globalized Applications . . . . . . . . . . . . . . . . . . . . . . 403
Introduction to globalization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
About character encodings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406
Locales . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408
Processing a request in ColdFusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410
Tags and functions for globalizing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413
Handling data in ColdFusion MX. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416
CHAPTER 18: Debugging and Troubleshooting Applications . . . . . . . . . . . . . . 423
Configuring debugging in the ColdFusion MX Administrator . . . . . . . . . . . . . . 423
Using debugging information from browser pages. . . . . . . . . . . . . . . . . . . . . . . . 426
Controlling debugging information in CFML . . . . . . . . . . . . . . . . . . . . . . . . . . . 434
Using the cftrace tag to trace execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436
Using the cftimer tag to time blocks of code . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440
Using the Code Compatibility Analyzer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442
Troubleshooting common problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443
6 Contents
PART IV: Accessing and Using Data
CHAPTER 19: Introduction to Databases and SQL . . . . . . . . . . . . . . . . . . . . . . 447
What is a database? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447
Using SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452
Writing queries using an editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460
CHAPTER 20: Accessing and Retrieving Data . . . . . . . . . . . . . . . . . . . . . . . . . 465
Working with dynamic data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 465
Retrieving data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466
Outputting query data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469
Getting information about query results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471
Enhancing security with cfqueryparam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472
CHAPTER 21: Updating Your Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475
About updating your database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475
Inserting data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475
Updating data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 480
Deleting data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487
CHAPTER 22: Using Query of Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489
About record sets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489
About Query of Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491
Query of Queries user guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497
CHAPTER 23: Managing LDAP Directories. . . . . . . . . . . . . . . . . . . . . . . . . . . . 515
About LDAP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 516
The LDAP information structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 517
Using LDAP with ColdFusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 520
Querying an LDAP directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 521
Updating an LDAP directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 527
Advanced topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 538
CHAPTER 24: Building a Search Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547
About Verity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547
Creating a search tool for ColdFusion applications . . . . . . . . . . . . . . . . . . . . . . . 553
Creating a search page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 561
Enhancing search results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 564
Working with data returned from a query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572
Contents 7
CHAPTER 25: Using Verity Search Expressions . . . . . . . . . . . . . . . . . . . . . . . . 581
About Verity query types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 581
Using simple queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 582
Using explicit queries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 583
Using natural queries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 587
Using Internet queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 587
Composing search expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591
Refining your searches with zones and fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . 601
PART V: Requesting and Presenting Information
CHAPTER 26: Introduction to Retrieving and Formatting Data . . . . . . . . . . . . . 609
Using forms in ColdFusion MX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 609
Working with action pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 613
Working with queries and data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 617
Returning results to the user . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 621
Dynamically populating list boxes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 625
Creating dynamic check boxes and multiple-selection list boxes . . . . . . . . . . . . . 627
CHAPTER 27: Building Dynamic Forms with cfform Tags . . . . . . . . . . . . . . . . . 631
Creating custom forms with the cfform tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 631
Building tree controls with the cftree tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 634
Building drop-down list boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 642
Building slider bar controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 643
Creating data grids with the cfgrid tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 644
Embedding Java applets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 655
CHAPTER 28: Validating Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 659
About ColdFusion MX validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 659
Validating form fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 667
Handling invalid data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 669
Masking form input values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 670
Validating form data with regular expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . 671
Validating form data using hidden fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675
Validating form input and handling errors with JavaScript . . . . . . . . . . . . . . . . . 680
Validating data with the IsValid function and the cfparam tag. . . . . . . . . . . . . . . 683
CHAPTER 29: Creating Forms in Macromedia Flash. . . . . . . . . . . . . . . . . . . . . 687
About Flash forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 687
Building Flash forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 689
Binding data in Flash forms. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 699
Setting styles and skins in Flash forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 700
Using ActionScript in Flash forms. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 704
Best practices for Flash forms. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 707
8 Contents
CHAPTER 30: Creating Skinnable XML Forms . . . . . . . . . . . . . . . . . . . . . . . . . 709
About XML skinnable forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 709
Building XML skinnable forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 712
ColdFusion XML format. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 715
Creating XSLT skins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 728
CHAPTER 31: Creating Charts and Graphs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 733
About charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 733
Creating a basic chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 734
Charting data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 735
Controlling chart appearance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 743
Creating charts: examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 751
Administering charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 756
Writing a chart to a variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 756
Linking charts to URLs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 758
CHAPTER 32: Creating Reports for Printing . . . . . . . . . . . . . . . . . . . . . . . . . . . 763
About printable output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 763
Creating PDF and FlashPaper output with the cfdocument tag. . . . . . . . . . . . . . 764
Creating reports with the ColdFusion MX 7 reporting . . . . . . . . . . . . . . . . . . . . 770
Font management with printable reports. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 804
Creating reports with Crystal Reports (Windows only) . . . . . . . . . . . . . . . . . . . . 805
CHAPTER 33: Using the Flash Remoting Service . . . . . . . . . . . . . . . . . . . . . . . 807
About using the Flash Remoting service with ColdFusion . . . . . . . . . . . . . . . . . . 807
Configuring the Flash Remoting Gateway. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 809
Using the Flash Remoting service with ColdFusion pages . . . . . . . . . . . . . . . . . . 812
Using Flash with CFCs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 817
Using the Flash Remoting service with ColdFusion Java objects . . . . . . . . . . . . . 819
Handling errors with ColdFusion and Flash . . . . . . . . . . . . . . . . . . . . . . . . . . . . 820
CHAPTER 34: Using Server-Side ActionScript . . . . . . . . . . . . . . . . . . . . . . . . . 823
About server-side ActionScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 823
Connecting to the Flash Remoting service. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 826
Using server-side ActionScript functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 827
Global and request scope objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 829
About the CF.query function and data sources . . . . . . . . . . . . . . . . . . . . . . . . . . 829
Using the CF.query function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 831
Building a simple application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 833
About the CF.http function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 836
Using the CF.http function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 837
Contents 9
PART VI: Using Web Elements and External Objects
CHAPTER 35: Using XML and WDDX. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 843
About XML and ColdFusion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 843
The XML document object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 844
ColdFusion XML tag and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 850
Using an XML object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 852
Creating and saving an XML document object . . . . . . . . . . . . . . . . . . . . . . . . . . 856
Modifying a ColdFusion XML object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 858
Validating XML documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 868
Transforming documents with XSLT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 869
Extracting data with XPath . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 869
Example: using XML in a ColdFusion application . . . . . . . . . . . . . . . . . . . . . . . 870
Moving complex data across the web with WDDX . . . . . . . . . . . . . . . . . . . . . . . 875
Using WDDX. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 879
CHAPTER 36: Using Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 885
Web services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 885
Working with WSDL files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 888
Consuming web services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 891
Publishing web services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 898
Using request and response headers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 907
Handling complex data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 909
Troubleshooting SOAP requests and responses . . . . . . . . . . . . . . . . . . . . . . . . . . 914
CHAPTER 37: Integrating J2EE and Java Elements in
CFML Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 917
About ColdFusion, Java, and J2EE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 917
Using JSP tags and tag libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 921
Interoperating with JSP pages and servlets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 922
Using Java objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 928
CHAPTER 38: Integrating COM and CORBA Objects in
CFML Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 945
About COM and CORBA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 945
Creating and using objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 947
Getting started with COM and DCOM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 948
Creating and using COM objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 951
Getting started with CORBA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 961
Creating and using CORBA objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 961
CORBA example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 969
10 Contents
PART VII: Using External Resources
CHAPTER 39: Sending and Receiving E-Mail . . . . . . . . . . . . . . . . . . . . . . . . . . 973
Using ColdFusion with mail servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 973
Sending e-mail messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 974
Sample uses of the cfmail tag. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 977
Using the cfmailparam tag. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 981
Receiving e-mail messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 983
Handling POP mail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 985
CHAPTER 40: Interacting with Remote Servers . . . . . . . . . . . . . . . . . . . . . . . . 991
About interacting with remote servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 991
Using cfhttp to interact with the web . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 992
Creating a query object from a text file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 994
Using the cfhttp Post method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 996
Performing file operations with cfftp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 999
CHAPTER 41: Managing Files on the Server . . . . . . . . . . . . . . . . . . . . . . . . . . 1003
About file management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1003
Using cffile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1003
Using cfdirectory. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1012
Using cfcontent. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1014
CHAPTER 42: Using Event Gateways . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1019
About event gateways . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1020
Event gateway facilities and tools. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1024
Structure of an event gateway application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1027
Configuring an event gateway instance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1028
Developing an event gateway application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1029
Deploying event gateways and applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1037
Using the CFML event gateway for asynchronous CFCs. . . . . . . . . . . . . . . . . . 1038
Using the example event gateways and gateway applications . . . . . . . . . . . . . . . 1040
CHAPTER 43: Using the Instant Messaging Event Gateways . . . . . . . . . . . . . 1047
About ColdFusion and instant messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1047
Configuring an IM event gateway . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1050
Handling incoming messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1052
Sending outgoing messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1053
Sample IM message handling application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1054
Using the GatewayHelper object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1058
Contents 11
CHAPTER 44: Using the SMS Event Gateway . . . . . . . . . . . . . . . . . . . . . . . . 1065
About SMS and ColdFusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1065
Configuring an SMS event gateway. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1071
Handling incoming messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1073
Sending outgoing messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1075
ColdFusion MX SMS development tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1080
Sample SMS application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1082
CHAPTER 45: Creating Custom Event Gateways . . . . . . . . . . . . . . . . . . . . . . 1085
Event gateway architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1085
Event gateway elements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1086
Building an event gateway . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1092
Deploying an event gateway . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1100
INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1103
12 Contents

INTRODUCTION

About ColdFusion MX Documentation

ColdFusion MX Developer’s Guide provides the tools needed to develop Internet applications using Macromedia ColdFusion MX. This manual is intended for web application programmers who are learning ColdFusion MX or wish to extended their ColdFusion MX programming knowledge. It provides a solid grounding in the tools that ColdFusion MX provides to develop web applications.
Because of the power and flexibility of ColdFusion MX, you can create many different types of web applications of varying complexity. As you become more familiar with the material presented in this manual, and begin to develop your own applications, you will want to refer to CFML Reference for details about various tags and functions.

Contents

Using this manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Accessing the ColdFusion MX documentation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

Using this manual

This manual can to help anyone with a basic understanding of HTML learn to develop ColdFusion MX applications. However, this manual is most useful if you have basic ColdFusion experience, or have read Getting Started Building ColdFusion MX Applications. The Getting Started Building ColdFusion MX Applications manual provides an introduction to ColdFusion and helps you develop the basic knowledge that will make using this manual easier.
Approaches to using this manual
This section describes approaches to using this manual for beginning ColdFusion developers, developers with some experience who want to develop expertise, and advanced developers who want to learn about the new and enhanced features of ColdFusion MX.
13
Beginning with ColdFusion
If you are learning ColdFusion, it might be most effective to read this manual in the following order:
1.
Chapter 1, “Introducing ColdFusion MX” through Chapter 4, “Using Expressions and Number Signs” to learn the basics of CFML.
2.
Chapter 19, “Introduction to Databases and SQL” through Chapter 21, “Updating Your Database” to learn about using databases.
3.
Chapter 26, “Introduction to Retrieving and Formatting Data” and Chapter 27, “Building Dynamic Forms with cfform Tags” to learn about requesting data from users.
After you read these chapters, you should have a basic understanding of the basic elements of ColdFusion, and be able to create simple ColdFusion applications. To learn to produce more complete and robust applications, you could proceed with the following chapters:
4.
Chapter 13, “Designing and Optimizing a ColdFusion Application” through Chapter 18, “Debugging and Troubleshooting Applications” to learn how to build a complete ColdFusion
application.
5.
Chapter 22, “Using Query of Queries” to learn how to use queries effectively.
6.
Chapter 5, “Using Arrays and Structures” through Chapter 10, “Building and Using ColdFusion Components” to learn to use more advanced features of CFML, including ways to
reuse code.
You can then read the remaining chapters as you add new features to your ColdFusion application.
Developing an in-depth knowledge of ColdFusion
If you have a basic understanding of ColdFusion as presented in Getting Started Building ColdFusion MX Applications or the Fast Track to ColdFusion course, you might want to start at
Chapter 1 and work through to the end of the book, skipping any specialized chapters that you are unlikely to need.
Learning about new and modified ColdFusion features
If you are an advanced ColdFusion developer, you might want to learn about new or changed ColdFusion features. The following chapters document features that are new or substantially enhanced in ColdFusion MX 7:
Chapter 24, “Building a Search Interface”
Chapter 25, “Using Verity Search Expressions”
Chapter 27, “Building Dynamic Forms with cfform Tags”
Chapter 28, “Validating Data”
Chapter 29, “Creating Forms in Macromedia Flash”
Chapter 30, “Creating Skinnable XML Forms”
Chapter 32, “Creating Reports for Printing”
14 Introduction: About ColdFusion MX Documentation
Chapter 42, “Using Event Gateways”
Chapter 43, “Using the Instant Messaging Event Gateways”
Chapter 44, “Using the SMS Event Gateway”
Chapter 45, “Creating Custom Event Gateways”
Nearly all chapters contain information that is new in ColdFusion MX 7, so you should also review all other chapters for useful information. The index and the table of contents are useful tools for finding new features or changed documentation.
Note: If you are moving from ColdFusion 4.5 or 5, start by reading Migrating ColdFusion 5 Applications, available on the Macromedia website.
ColdFusion features described in this manual
ColdFusion provides a comprehensive set of features for developing and managing Internet applications. These features enhance speed and ease-of-development, and let you dynamically deploy your applications, integrate new and legacy technologies, and build secure applications.
The following table describes the primary ColdFusion features that are discussed in this manual, and lists the chapters that describe them. This table is only a summary of major CFML features; this manual also includes information about other features. Also, this table does not include features that are described in other manuals.
Feature Description Chapters
CFML CFML is a fully featured tag-oriented Internet application language.
It includes a wide range of tags, functions, variables, and expressions.
CFScript CFScript is a server-side scripting language that provides a subset
of ColdFusion functionality in script syntax.
Regular expressions
Reusable elements
User-defined functions (UDFs)
ColdFusion components
Custom CFML tags
ColdFusion extension (CFX) tags
ColdFusion provides several functions that use regular expressions for string manipulation. It also lets you use regular expressions in text input tags.
ColdFusion lets you create several types of elements, such as user­defined functions and ColdFusion components, that you write once and can use many times.
You can use CFScript or the functions. These functions can incorporate all of the built-in ColdFusion tags and functions, plus other extensions.
ColdFusion components encapsulate multiple functions and related data in a single logical unit. ColdFusion components can have many uses, and are particularly useful in creating web services and Flash interfaces for your application.
You can create custom ColdFusion tags using CFML. These tags can have bodies and can call other custom tags.
You can create custom tags in Java or C++. These tags can use features that are only available when using programming languages. However, CFX tags cannot have tag bodies.
cffunction tag to create your own
2–5
6
7, 28
8–12
9
10
11
12
Using this manual 15
Feature Description Chapters
ColdFusion application structure
ColdFusion supports many ways of building an application, and includes specific features, such as the Application.cfc file or Application.cfm page, built-in security features, and shared scopes,
13–17
that help you optimize your application structure.
Error handling mechanisms
Shared and persistent variable scopes
Code locking You lock sections of code that access in-memory shared scopes or
ColdFusion provides several mechanisms for handling data, including custom error pages and exception-handling tags and functions, such as
cftry and cfcatch.
Using shared and persistent scopes, you can make data available to a single user over one or many browser sessions, or to multiple users of an application or server.
14
15
15 use external resources that are not safe for multiple simultaneous access.
Application security
ColdFusion provides mechanisms, including the
cflogin tag, for
authenticating users and authorizing them to access specific
16
sections of your application. You can also use resource security, which secures access to ColdFusion resources based on the ColdFusion page location.
Application globalization
ColdFusion supports global applications that use different character sets and locales, and provides tags and functions
17
designed to support globalizing your applications.
Debugging tools Using debugging output, the
cftrace tag, logging features, and the
18 Code Analyzer, you can locate and fix coding errors.
Database access and management
ColdFusion can access SQL databases to retrieve, add, and modify data. This feature is one of the core functions of many dynamic
19–21
applications.
Queries of Queries You can use a subset of standard SQL within ColdFusion to
22 manipulate any data that is represented as a record set, including database query results, LDAP (Lightweight Directory Access Protocol) directory information, and other data.
LDAP directory access and management
Indexing and searching data
ColdFusion applications can access and manipulate data in LDAP directory services. These directories are often used for security validation data and other directory-like information.
ColdFusion applications can provide full-text search capabilities for documents and data sources using the Verity search engine.
Dynamic forms With ColdFusion, you can use HTML and forms to control the data
displayed by a dynamic web page. You can also use the
cfform tag
23
24–25
26–30
to enrich your forms with sophisticated graphical controls, and perform input data validation.
Validating data ColdFusion provides several ways to validate data in forms and in
28 CFML variables.
Flash forms ColdFusion can display forms using Macromedia Flash, which
29 presents a pleasing appearance and includes features such as accordion and tab navigators.
16 Introduction: About ColdFusion MX Documentation
Feature Description Chapters
XML skinnable forms
Data graphing You can use the
Reports and printable output
ColdFusion can convert your CFML forms into XML and format the XML using XSLT skins and style sheets.
cfchart tag to display your data graphically. 31
You can create output that is formatted for print as PDF or FlashPaper documents. You can also use ColdFusion reporting to
30
32
create banded reports for display or printing.
Macromedia Flash integration
Server-side ActionScript
You can use native Flash connectivity built into ColdFusion to help build dynamic Flash user interfaces for ColdFusion applications.
Macromedia Flash Remoting lets Macromedia Flash MX developers create server-side ActionScript. ActionScript files can
33
34
directly access ColdFusion query and HTTP features through two
XML document processing and creation
functions:
ColdFusion applications can create, use, and manipulate XML (Extensible Markup Language) documents. ColdFusion also provides tools to use WDDX (Web Distributed Data Exchange), an
CF.query and CF.http.
35
XML dialect for transmitting structured data.
Web services ColdFusion applications can use available SOAP (Simple Object
36 Access Protocol)-based web services, including Microsoft .NET services. ColdFusion applications can also use ColdFusion components to provide web services to other applications over the Internet.
Java and J2EE integration
You can integrate J2EE elements, including JSP (JavaServer Pages) pages, JSP tag libraries, and Java objects, including EJBs
37
(Enterprise JavaBeans), into your ColdFusion application.
COM and CORBA objects
The
cfobject tag lets you use COM (Component Object Model) or
DCOM (Distributed Component Object Model) and CORBA
38
(Common Object Request Broker) objects in your ColdFusion applications.
E-mail messages You can add interactive e-mail features to your ColdFusion
applications using the
HTTP and FTP The
cfhttp and cfftp tags provide simple methods of using HTTP
cfmail and cfpop tags.
39
40 (Hypertext Transfer Protocol) and FTP (File Transfer Protocol) communications in your application.
File and directory access
Event gateways ColdFusion event gateways let ColdFusion applications
You can use the
cffile, cfdirectory, and cfcontent tags to read,
write, and manage files and directories on the server.
41
42–45 asynchronously react to or generate external events or messages.
Instant messaging event gateways
Your ColdFusion application can communicate with XMPP (Jabber) or IBM Sametime instant messaging clients using the
43
ColdFusion IM gateways.
Using this manual 17
Feature Description Chapters
SMS event gateway
Creating gateways You can write your own event gateways in Java and integrate them
Your ColdFusion MX application can communicate with short message service (SMS) devices, such as mobile phones, using the ColdFusion SMS event gateway.
into ColdFusion MX.

Accessing the ColdFusion MX documentation

The ColdFusion MX documentation is designed to provide support for the complete spectrum of participants.
Documentation set
The ColdFusion MX 7 documentation set includes the following titles:
Book Description
Installing and Using ColdFusion MX
Configuring and Administering ColdFusion MX
ColdFusion MX Developer’s Guide
Getting Started Building ColdFusion MX Applications
CFML Reference Provides descriptions, syntax, usage, and code examples for all ColdFusion
CFML Quick Reference Provides a brief guide that shows the syntax of ColdFusion tags, functions,
Describes system installation and basic configuration for Windows, Solaris, and Linux. To see this manual, go to www.macromedia.com/go/
livedocs_cfmx7docs_installing.
Part I describes how to manage the ColdFusion environment, including connecting to your data sources and configuring security for your applications. Part II describes Verity search tools and utilities that you can use for configuring the Verity Search Server engine, as well as creating, managing, and troubleshooting Verity collections. To see this manual, go to
www.macromedia.com/go/livedocs_cfmx7docs_configadmin.
Describes how to develop your dynamic web applications, including retrieving and updating your data, using structures, and forms. This manual includes two volumes. To see this manual, go to www.macromedia.com/go/
livedocs_cfmx7docs_dev.
Contains an overview of ColdFusion features and application development procedures. Includes a tutorial that guides you through the process of developing an example ColdFusion application. To see this manual, go to
www.macromedia.com/go/livedocs_cfmx7docs_gs.
tags, functions, and variables. This manual includes two volumes. To see this manual, go to www.macromedia.com/go/
livedocs_cfmx7docs__cfml_reference.
and variables.
44
45
Viewing online documentation
All ColdFusion MX documentation is available online in HTML and Adobe Acrobat Portable Document Format (PDF) files. Go to the documentation home page for ColdFusion MX on the Macromedia website: www.macromedia.com.
18 Introduction: About ColdFusion MX Documentation
CHAPTER 1

Introducing ColdFusion MX

This chapter describes Macromedia ColdFusion MX and the role it plays in developing dynamic Internet applications. This chapter also introduces the topics discussed in this manual.

Contents

About Internet applications and web application servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
About ColdFusion MX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
About J2EE and the ColdFusion architecture. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

About Internet applications and web application servers

With ColdFusion MX, you develop Internet applications that run on web application servers. The following sections introduce Internet applications and web application servers. Later sections explain the specific role that ColdFusion MX plays in this environment.
About web pages and Internet applications
The Internet has evolved from a collection of static HTML pages to an application deployment platform. First, the Internet changed from consisting of static web pages to providing dynamic, interactive content. Rather than providing unchanging content where organizations merely advertise goods and services, dynamic pages enable companies to conduct business ranging from e-commerce to managing internal business processes. For example, a static HTML page lets a bookstore publish its location, list services such as the ability to place special orders, and advertise upcoming events like book signings. A dynamic website for the same bookstore lets customers order books online, write reviews of books they read, and even get suggestions for purchasing books based on their reading preferences.
More recently, the Internet has become the underlying infrastructure for a wide variety of applications. With the arrival of technologies such as XML, web services, J2EE (Java 2 Platform, Enterprise Edition), and Microsoft .NET, the Internet has become a multifaceted tool for integrating business activities. Now, enterprises can use the Internet to integrate distributed activities, such as customer service, order entry, order fulfillment, and billing.
19
ColdFusion MX is a rapid application development environment that lets you build dynamic websites and Internet applications quickly and easily. It lets you develop sophisticated websites and Internet applications without knowing the details of many complex technologies, yet it lets advanced developers take advantage of the full capabilities of many of the latest Internet technologies.
About web application servers
To understand ColdFusion, you must first understand the role of web application servers. Typically, web browsers make requests, and web servers, such as Microsoft Internet Information Server (IIS) and the Apache web server, fulfill those requests by returning the requested information to the browser. This information includes, but is not limited to, HTML and Macromedia Flash files.
A web server’s capabilities are limited because all it does is wait for requests to arrive and attempt to fulfill those requests as soon as possible. A web server does not let you do the following tasks:
Interact with a database, other resource, or other application.
Serve customized information based on user preferences or requests.
Validate user input.
A web server, basically, locates information and returns it to a web browser.
To extend the capabilities of a web server, you use a web application server, a software program that extends the web server’s capabilities to do tasks such as those in the preceding list.
20 Chapter 1: Introducing ColdFusion MX
How a web server and web application server work together
The following steps explain how a web server and web application server work together to process a page request:
1.
The user requests a page by typing a URL in a browser, and the web server receives the request.
2.
The web server looks at the file extension to determine whether a web application server must process the page. Then, one of the following actions occur:
If the user requests a file that is a simple web page (often one with an HTM or HTML
extension), the web server fulfills the request and sends the file to the browser.
If the user requests a file that is a page that a web application server must process (one with
a CFM, CFML, or CFC extension for ColdFusion requests), the web server passes the request to the web application server. The web application server processes the page and sends the results to the web server, which returns those results to the browser. The following figure shows this process:
1
Web browser
requests
a web page.
2
Web server receives the
page request.
3
Web server instructs
application server
to process the page.
4
The application server
processes the page
and generates output.
5
The web server
sends the output
to the browser.
Because web application servers interpret programming instructions and generate output that a web browser can interpret, they let web developers build highly interactive and data-rich websites, which can do tasks such as the following:
Query other database applications for data.
Dynamically populate form elements.
Dynamically generate Flash application data.
Provide application security.
Integrate with other systems using standard protocols such as HTTP, FTP, LDAP, POP,
and SMTP.
Create shopping carts and e-commerce websites.
Respond with an e-mail message immediately after a user submits a form.
Return the results of keyword searches.
About Internet applications and web application servers 21

About ColdFusion MX

ColdFusion MX is a rapid scripting environment server for creating dynamic Internet Applications. ColdFusion Markup Language (CFML) is an easy-to-learn tag-based scripting language, with connectivity to enterprise data and powerful built-in search and charting capabilities. ColdFusion MX enables developers to easily build and deploy dynamic websites, content publishing systems, self-service applications, commerce sites, and more.
ColdFusion MX consists of the following core components:
ColdFusion scripting environment
CFML
ColdFusion MX Administrator
Verity Search Server
The following sections describe these core components in more detail.
The ColdFusion scripting environment
The ColdFusion scripting environment provides an efficient development model for Internet applications. At the heart of the ColdFusion scripting environment is the ColdFusion Markup Language (CFML), a tag-based programming language that encapsulates many of the low-level details of web programming in high-level tags and functions.
ColdFusion Markup Language
ColdFusion Markup Language (CFML) is a tag-based language, similar to HTML, that uses special tags and functions. With CFML, you can enhance standard HTML files with database commands, conditional operators, high-level formatting functions, and other elements to rapidly produce easy-to-maintain web applications. However, CFML is not limited to enhancing HTML. For example, you can create Macromedia Flash MX applications that consist entirely of Flash elements and CFML. Similarly, you can use CFML to create web services for use by other applications.
The following sections briefly describe basic CFML elements. For more information, see
Chapter 2, “Elements of CFML,” on page 27.
CFML tags
CFML looks similar to HTML—it includes starting and, in most cases, ending tags, and each tag is enclosed in angle brackets. All ending tags are preceded with a forward slash (/) and all tag names are preceded with
<cftagname>
tag body text and CFML
</cftagname>
cf; for example:
CFML increases productivity by providing a layer of abstraction that hides many low-level details involved with Internet application programming. At the same time, CFML is extremely powerful and flexible. ColdFusion lets you easily build applications that integrate files, databases, legacy systems, mail servers, FTP servers, objects, and components.
22 Chapter 1: Introducing ColdFusion MX
CFML includes approximately 110 tags. ColdFusion tags serve many functions. They provide programming constructs, such as conditional processing and loop structures. They also provide services, such as charting and graphing, full-text search, access to protocols such as FTP, SMTP/ POP, and HTTP, and much more. The following table lists a few examples of commonly used ColdFusion tags:
Tag Purpose
cfquery
cfoutput
cfset
cfmail
cfchart
cfobject
Establishes a connection to a database (if one does not exist), executes a query, and returns results to the ColdFusion environment.
Displays output that can contain the results of processing ColdFusion functions, variables, and expressions.
Sets the value of a ColdFusion variable.
Lets an application send SMTP mail messages using application variables, query results, or server files. (Another tag,
Converts application data or query results into graphs, such as bar charts or pie charts, in Flash, JPG, or PNG format.
Invokes objects written in other programming languages, including COM (Component Object Model) components, Java objects such as Enterprise JavaBeans, or Common CORBA (Object Request Broker Architecture) objects.
cfpop, gets mail.)
CFML Reference describes the CFML tags in detail.
CFML functions and CFScript
CFML includes approximately 280 built-in functions. These functions perform a variety of roles, including string manipulation, data management, and system functions. CFML also includes a built-in scripting language, CFScript, that lets you write code in a manner that is familiar to programmers and JavaScript writers.
CFML extensions
You can extend CFML further by creating custom tags or user-defined functions (UDFs), or by integrating COM, C++, and Java components (such as JSP tag libraries). You can also create ColdFusion components (CFCs), which encapsulate related functions and properties and provide a consistent interface for accessing them.
All these features let you easily create reusable functionality that is customized to the types of applications or websites that you are building.
CFML development tools
Macromedia Dreamweaver MX 2004 helps you develop ColdFusion applications efficiently. It includes many features that simplify and enhance ColdFusion development, including tools for debugging CFML. Because CFML is written in an HTML-like text format, and you often use HTML in ColdFusion pages, you can also use an HTML editor or a text editor, such as Notepad, to write ColdFusion applications.
About ColdFusion MX 23
Verity Search Server
The Verity Search Server (also called the Verity search engine) provides full text search capability for documents and data on a ColdFusion MX site.
ColdFusion MX Administrator
ColdFusion MX Administrator configures and manages the ColdFusion application server. It is a secure web-based application that you can access using any web browser, from any computer with an Internet connection.
For more information about ColdFusion MX Administrator, see Configuring and Administering ColdFusion MX.

About J2EE and the ColdFusion architecture

As the Internet software market has matured, the infrastructure services required by distributed Internet applications, including ColdFusion applications, have become increasingly standardized. The most widely adopted standard today is the Java 2 Platform, Enterprise Edition (J2EE) specification. J2EE provides a common set of infrastructure services for accessing databases, protocols, and operating system functionality, across multiple operating systems.
About ColdFusion MX and the J2EE platform
ColdFusion MX is implemented on the Java technology platform and uses a J2EE application server for many of its base services, including database connectivity, naming and directory services, and other runtime services. ColdFusion MX can be configured to use an embedded J2EE server (in the server configuration) or it can be deployed as a J2EE application on an independent J2EE application server (in the multiserver configuration or the J2EE configuration). ColdFusion MX Enterprise includes a fully featured version of the Macromedia JRun J2EE application server, or can be deployed on third-party J2EE servers such as IBM WebSphere and BEA WebLogic.
For more information on ColdFusion MX configurations, see Installing and Using ColdFusion MX.
By implementing the ColdFusion scripting environment on top of the J2EE platform, ColdFusion MX takes advantage of the power of the J2EE platform while also providing an easy­to-use scripting environment and built-in services. Moreover, because ColdFusion is built on a J2EE platform, you can easily integrate J2EE and Java functionality into your ColdFusion application. As a result, ColdFusion pages can do any of the following:
Share session data with JSPs (Java Server Pages) and Java servlets.
Import custom JSP tag libraries and use them like ColdFusion custom tags.
Integrate with Java objects, including the J2EE Java API, JavaBeans, and Enterprise JavaBeans.
For more information on using J2EE features in ColdFusion, see Chapter 37, “Integrating J2EE
and Java Elements in CFML Applications,” on page 917.
24 Chapter 1: Introducing ColdFusion MX
PART I

The CFML Programming Language

This part describes the elements of the CFML programming language. It tells you how to use CFML tags, functions, variables and expressions, the CFScript scripting language, and regular expressions.
The following chapters are included:
Chapter 2: Elements of CFML. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Chapter 3: Using ColdFusion Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Chapter 4: Using Expressions and Number Signs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Chapter 5: Using Arrays and Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Chapter 6: Extending ColdFusion Pages with CFML Scripting . . . . . . . . . . . . . . . . . . . . . . . 123
Chapter 7: Using Regular Expressions in Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
PART I
CHAPTER 2

Elements of CFML

This chapter provides an overview of the basic elements of CFML, including tags, functions, constants, variables, expressions, and CFScript. The chapters in Part I of this manual describe these topics in detail.

Contents

CFML Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
ColdFusion components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Constants. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Flow control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Character case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Special characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Reserved words . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
CFScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
27

CFML Basics

This chapter introduces and describes the basic elements of CFML. These elements make CFML a powerful tool for developing interactive web applications. Because CFML is a dynamic application development tool, it has many of the features of a programming language, including the following:
Functions
Expressions
Variables and constants
Flow-control constructs such as if-then and loops
CFML also has a “language within a language,” CFScript, which enables you to use a syntax similar to JavaScript for many operations.
This chapter introduces these elements and other basic CFML entities such as comments, data types, escape characters, and reserved words.
The remainder of Part I of this manual provides more detailed information on many of the basic CFML elements. The rest of this manual helps you use these elements effectively in your applications.

Comments

ColdFusion comments have a similar format to HTML comments. However, they use three dash characters instead of two; for example:
<!--- This is a ColdFusion Comment. Browsers do not receive it. --->
The ColdFusion server removes all ColdFusion comments from the page before returning it to the web server. As a result, the page that a user browser receives does not include the comment, and users cannot see it even if they view the page source.
You can embed CFML comments in begin tags (not just tag bodies), functions calls, and variable text in number signs. ColdFusion ignores the text in comments such as the following:
<cfset MyVar = var1 <!--- & var2 --->> <cfoutput>#Dateformat(now() <!---, "dddd, mmmm yyyy" --->)#</cfoutput>
This technique can be useful if you want to temporarily comment out parts of expressions or optional attributes or arguments.
You can also nest comments, as the following example shows:
<!--- disable this code <!--- display error message ---> <cfset errormessage1="Oops!"> <cfoutput> #errormessage1# </cfoutput>
--->
This is useful if you want to temporarily disable a section of code while you test your application.
You can embed comments within comments, however, you should use this technique carefully.
28 Chapter 2: Elements of CFML
Note: You cannot embed comments inside a tag name or function name, such as
<cf_My<!--- New --->CustomTag>. You also cannot embed comments inside strings, as in the
following example:
IsDefined("My<!--- New --->Variable").

Tags

ColdFusion tags tell the ColdFusion server that it must process information. The ColdFusion server only processes tag contents; it returns text outside of ColdFusion to the web server unchanged. Macromedia ColdFusion MX provides a wide variety of built-in tags and lets you create custom tags.
Tag syntax
ColdFusion tags have the same format as HTML tags. They are enclosed in angle brackets (< and >) and can have zero or more named attributes. Many ColdFusion tags have bodies; that is, they have beginning and end tags with text to be processed between them. For example:
<cfoutput>
Hello #YourName#! <br>
</cfoutput>
Other tags, such as cfset and cfftp, never have bodies; all the required information goes between the beginning (<) character and the ending (>) character, as in the following example:
<cfset YourName="Bob">
Sometimes, although the tag can have a body, you do not need to put anything in it because the attributes specify all the required information. You can omit the end tag and put a forward slash character before the closing (>) character, as in the following example:
<cfexecute name="C:\winNT\System32\netstat.exe" arguments = "-e"
outputfile="C:\Temp\out.txt" timeout = "1" />
Note: The tag encloses an assignment statement that assigns a value to a variable. The function without assigning a value to a result variable.
cfset tag differs from other tags in that it has neither a body nor arguments. Instead, the
cfset tag can also call a
Built-in tags
Over 110 built-in tags make up the heart of ColdFusion. These tags have many uses, including the following:
Manipulating variables
Creating interactive forms
Accessing and manipulating databases
Displaying data
Controlling the flow of execution on the ColdFusion page
Handling errors
Processing ColdFusion pages
Managing the CFML application framework
Manipulating files and directories
Tags 29
Using external tools and objects, including Verity collections, COM, Java, and CORBA
objects, and executable programs
Using protocols, such as mail, http, ftp, and pop
Much of this document describes how to use these tags effectively. CFML Reference documents each tag in detail.
Custom tags
ColdFusion lets you create custom tags. You can create two types of custom tags:
CFML custom tags that are ColdFusion pages
CFX tags that you write in a programing language such as Java or C++
Custom tags can encapsulate frequently used business logic or display code. These tags enable you to place frequently used code in one place and call it from many places. Custom tags also let you abstract complex logic into a single, simple interface. They provide an easy way to distribute your code to others; you can even distribute encrypted versions of the tags to prevent access to the tag logic.
You can access a variety of free and commercial custom tags on the Macromedia developer’s exchange (www.macromedia.com/cfusion/exchange/index.cfm). They perform tasks ranging from checking if Cookies and JavaScript are enabled on the client's browser to moving items from one list box to another. Many of these tags are free and include source code.
CFML custom tags
When you write a custom tag in CFML, you can take advantage of all the features of the ColdFusion language, including all built-in tags and even other custom tags. CFML custom tags can include body sections and end tags. Because they are written in CFML, you do not need to know a programming language such as Java. CFML custom tags provide more capabilities than user-defined functions, but are less efficient.
For more information on CFML custom tags, see Chapter 11, “Creating and Using Custom
CFML Tags,” on page 241. For information about, and comparisons among, ways to reuse
ColdFusion code, including CFML custom tags, user-defined functions, and CFX tags, see
Chapter 8, “Creating ColdFusion Elements,” on page 161.
CFX Tags
CFX tags are ColdFusion custom tags that you write in a programming language such as Java or C++. These tags can take full advantage of all the tools and resources provided by these languages, including their access to runtime environments. CFX tags also generally execute faster than CFML custom tags because they are compiled. CFX tags can be cross-platform, but are often platform-specific, for example if they take advantage of COM objects or the Windows API.
For more information on CFX tags, see Chapter 12, “Building Custom CFXAPI Tags,” on
page 259.
30 Chapter 2: Elements of CFML
Loading...
+ 1110 hidden pages