Adobe ColdFusion MX 7.0 User guide

  • Hello! I am an AI chatbot trained to assist you with the Adobe ColdFusion MX 7.0 User guide. I’ve already reviewed the document and can help you find the information you need or explain it in simple terms. Just ask your questions, and providing more details will help me assist you more effectively!
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
3
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
4 Contents
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
Contents 5
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
6 Contents
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
Contents 7
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
8 Contents
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
Contents 9
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
10 Contents
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
Contents 11
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
12 Contents
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
13
INTRODUCTION
About ColdFusion MX Documentation
ColdFusion MX Developers 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.
14 Introduction: About ColdFusion MX Documentation
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”
Using this manual 15
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.
2–5
CFScript CFScript is a server-side scripting language that provides a subset
of ColdFusion functionality in script syntax.
6
Regular
expressions
ColdFusion provides several functions that use regular expressions
for string manipulation. It also lets you use regular expressions in
text input tags.
7, 28
Reusable
elements
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.
8–12
User-defined
functions
(UDFs)
You can use CFScript or the
cffunction tag to create your own
functions. These functions can incorporate all of the built-in
ColdFusion tags and functions, plus other extensions.
9
ColdFusion
components
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.
10
Custom CFML
tags
You can create custom ColdFusion tags using CFML. These tags
can have bodies and can call other custom tags.
11
ColdFusion
extension (CFX)
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.
12
16 Introduction: About ColdFusion MX Documentation
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,
that help you optimize your application structure.
13–17
Error handling
mechanisms
ColdFusion provides several mechanisms for handling data,
including custom error pages and exception-handling tags and
functions, such as
cftry and cfcatch.
14
Shared and
persistent variable
scopes
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.
15
Code locking You lock sections of code that access in-memory shared scopes or
use external resources that are not safe for multiple simultaneous
access.
15
Application
security
ColdFusion provides mechanisms, including the
cflogin tag, for
authenticating users and authorizing them to access specific
sections of your application. You can also use resource security,
which secures access to ColdFusion resources based on the
ColdFusion page location.
16
Application
globalization
ColdFusion supports global applications that use different
character sets and locales, and provides tags and functions
designed to support globalizing your applications.
17
Debugging tools Using debugging output, the
cftrace tag, logging features, and the
Code Analyzer, you can locate and fix coding errors.
18
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
applications.
19–21
Queries of Queries You can use a subset of standard SQL within ColdFusion to
manipulate any data that is represented as a record set, including
database query results, LDAP (Lightweight Directory Access
Protocol) directory information, and other data.
22
LDAP directory
access and
management
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.
23
Indexing and
searching data
ColdFusion applications can provide full-text search capabilities for
documents and data sources using the Verity search engine.
24–25
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
to enrich your forms with sophisticated graphical controls, and
perform input data validation.
26–30
Validating data ColdFusion provides several ways to validate data in forms and in
CFML variables.
28
Flash forms ColdFusion can display forms using Macromedia Flash, which
presents a pleasing appearance and includes features such as
accordion and tab navigators.
29
Feature Description Chapters
Using this manual 17
XML skinnable
forms
ColdFusion can convert your CFML forms into XML and format the
XML using XSLT skins and style sheets.
30
Data graphing You can use the
cfchart tag to display your data graphically. 31
Reports and
printable output
You can create output that is formatted for print as PDF or
FlashPaper documents. You can also use ColdFusion reporting to
create banded reports for display or printing.
32
Macromedia Flash
integration
You can use native Flash connectivity built into ColdFusion to help
build dynamic Flash user interfaces for ColdFusion applications.
33
Server-side
ActionScript
Macromedia Flash Remoting lets Macromedia Flash MX
developers create server-side ActionScript. ActionScript files can
directly access ColdFusion query and HTTP features through two
functions:
CF.query and CF.http.
34
XML document
processing and
creation
ColdFusion applications can create, use, and manipulate XML
(Extensible Markup Language) documents. ColdFusion also
provides tools to use WDDX (Web Distributed Data Exchange), an
XML dialect for transmitting structured data.
35
Web services ColdFusion applications can use available SOAP (Simple Object
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.
36
Java and J2EE
integration
You can integrate J2EE elements, including JSP (JavaServer
Pages) pages, JSP tag libraries, and Java objects, including EJBs
(Enterprise JavaBeans), into your ColdFusion application.
37
COM and CORBA
objects
The
cfobject tag lets you use COM (Component Object Model) or
DCOM (Distributed Component Object Model) and CORBA
(Common Object Request Broker) objects in your ColdFusion
applications.
38
E-mail messages You can add interactive e-mail features to your ColdFusion
applications using the
cfmail and cfpop tags.
39
HTTP and FTP The
cfhttp and cfftp tags provide simple methods of using HTTP
(Hypertext Transfer Protocol) and FTP (File Transfer Protocol)
communications in your application.
40
File and directory
access
You can use the
cffile, cfdirectory, and cfcontent tags to read,
write, and manage files and directories on the server.
41
Event gateways ColdFusion event gateways let ColdFusion applications
asynchronously react to or generate external events or messages.
42–45
Instant messaging
event gateways
Your ColdFusion application can communicate with XMPP
(Jabber) or IBM Sametime instant messaging clients using the
ColdFusion IM gateways.
43
Feature Description Chapters
18 Introduction: About ColdFusion MX Documentation
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:
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.
SMS event
gateway
Your ColdFusion MX application can communicate with short
message service (SMS) devices, such as mobile phones, using the
ColdFusion SMS event gateway.
44
Creating gateways You can write your own event gateways in Java and integrate them
into ColdFusion MX.
45
Book Description
Installing and Using
ColdFusion MX
Describes system installation and basic configuration for Windows, Solaris,
and Linux. To see this manual, go to www.macromedia.com/go/
livedocs_cfmx7docs_installing.
Configuring and
Administering
ColdFusion MX
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.
ColdFusion MX
Developer’s Guide
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.
Getting Started
Building
ColdFusion MX
Applications
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.
CFML Reference Provides descriptions, syntax, usage, and code examples for all ColdFusion
tags, functions, and variables. This manual includes two volumes. To see
this manual, go to www.macromedia.com/go/
livedocs_cfmx7docs__cfml_reference.
CFML Quick Reference Provides a brief guide that shows the syntax of ColdFusion tags, functions,
and variables.
Feature Description Chapters
19
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.
20 Chapter 1: Introducing ColdFusion MX
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.
/