-
Developing ColdFusion Applications MacroMedia ColdFusion® 5 Macromedia® Incorporated
-
Copyright Notice © 1999–2001 Macromedia Incorporated. All rights reserved. This book, as well as the software described in it, is furnished under license and may be used or copied only in accordance with the terms of such license. The content of this manual is furnished for informational use only, is subject to change without notice, and should not be construed as a commitment by Macromedia, Incorporated.
-
Contents About This Book ............................... xv Intended Audience . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvi New Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvi Developer Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii About ColdFusion Documentation . . . . . . . . . . . . . . . .
-
iv Contents Working with Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 About variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Adding more variables to the application . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Development Considerations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Chapter 3 Querying a Database ....
-
v Using HTML tables to display query results . . . . . . . . . . . . . . . . . . . . . . . . . . Formatting individual data items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Performing pattern matching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Filtering data based on multiple conditions . . . . . . . . . . . . . . . . . . . . . . . . . . Creating table joins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
-
vi Contents Data entry form notes and considerations . . . . . . . . . . . . . . . . . . . . . . . . . . 103 Creating an action page to insert data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 Updating Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 Creating an update form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 Creating an action page to update data . . . . . . . . .
-
vii Input Validation with JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 Handling failed validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 Example: validating an e-mail address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 Building Tree Controls with cftree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Grouping output from a query . . . . . . . . . . . . . . . . . . .
-
viii Contents Where is data accessible? High-level data exchange . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 Executing Custom Tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Tag instance data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Modes of execution . . . . . . . . . .
-
ix Client, Session, Application, and Server scope variables . . . . . . . . . . . . . . 214 Custom error handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 Web server security integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 Mapping an Application Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216 Processing Application.cfm and OnRequestEnd.cfm . . . . . . . . . . . . . . . . .
-
x Contents Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Reserved words . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
-
xi Using Query Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Simple query expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Explicit query expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Expression syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Composing search expressions . . . . . . . . . . . . . . . . .
-
xii Contents Evaluating the Results of a File Upload . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324 Moving, Renaming, Copying, and Deleting Server Files . . . . . . . . . . . . . . . . . . . . 326 Reading, Writing, and Appending to a Text File . . . . . . . . . . . . . . . . . . . . . . . . . . . 327 Reading a text file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327 Writing a text file . . . . . . . . . . . . . . . . . . . . . .
-
xiii Authenticating users in Application.cfm . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363 Checking for authentication and authorization . . . . . . . . . . . . . . . . . . . . . 365 Chapter 20 Using cfobject to Invoke Component Objects 367 . Component Object Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . About COM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . About CORBA . . . . . .
-
xiv Contents ZipBrowser Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397 Approaches to Debugging Java CFXs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398 Outputting debug information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398 Using the debugging classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399 Developing CFX Tags in C++. . . . . . . . . . . .
-
About This Book Developing ColdFusion Applications describes the process of developing Web applications using ColdFusion. In the first eight chapters, you can follow the instructions presented to learn how to create basic ColdFusion applications. Then, chapters nine through 19 cover various topics of interest in enhancing your applications. Finally, chapters 20 through 23 explain how to extend ColdFusion’s capabilities.
-
xvi About This Book Intended Audience Developing ColdFusion Applications is intended for Web application programmers who are learning ColdFusion orwish to extended their ColdFusion programming knowledge. It provides a solid grouding in the tools that ColdFusion provides to develop Web applications. The initial chapters provide e instructions for creating a basic ColdFusion application and are intended for those who are new to ColdFusion.
-
Developer Resources xvii Benefit Feature Description Enhanced performance Core engine tuning Take advantage of dramatically improved server performance and reduced memory usage to deliver faster, more scalable applications. Incremental page delivery Improve response time by delivering page output to users as it is built. Wire protocol database drivers Deliver high-performance ODBC connectivity using new drivers.
-
xviii About This Book designed to give you quick access to the entire range of online resources, as the following table describes. Resource Description URL Macromedia Web General information about Macromedia www.macromedia.com/ site products and services Information on ColdFusion Detailed product information on ColdFusion and related topics www.coldfusion.com/products/coldfusion/ Technical Support Professional support programs that Macromedia offers. www.coldfusion.
-
About ColdFusion Documentation xix Printed and online documentation set The ColdFusion documentation set consists of the following titles.
-
xx About This Book Getting Answers One of the best ways to solve particular programming problems is to tap into the vast expertise of the ColdFusion developer communities on the ColdFusion Forums. Other developers on the forum can help you figure out how to do just about anything with ColdFusion. The search facility can also help you search messages from the previous 12 months, allowing you to learn how others have solved a problem that you might be facing.
-
Chapter 1 Introduction to ColdFusion This chapter explains the difference between creating static Web pages with HTML and creating dynamic applications with ColdFusion. It also describes what ColdFusion is and how it works. Contents • A Quick Web Overview................................................................................................ 2 • Before You Begin ......................................................................................................... 3 • What is ColdFusion?.......
-
2 Chapter 1 Introduction to ColdFusion A Quick Web Overview Over the last few years, the Web changed from being simply a collection of static HTML pages to an application development platform. Rather than offering a space where organizations can merely advertise goods and services, similar to traditional yellow pages directories, companies conduct business ranging from e-commerce to managing internal business processes.
-
Before You Begin 3 Before You Begin Before you begin using ColdFusion to create your Web applications, you should be familiar with HTML, relational database design and management, and Structured Query Language (SQL). HTML You will find that ColdFusion tags (CFML) are similar in syntax to HTML tags, yet, unlike HTML, they enable you to create dynamic Web pages. You should understand how to create a basic HTML page, put information into tables, gather data in forms, and create links.
-
4 Chapter 1 Introduction to ColdFusion What is ColdFusion? ColdFusion lets you create page-based Web applications using ColdFusion Markup Language (CFML), the tag-based language you use to create server-side scripts that dynamically control data integration; application logic; and user interface generation. ColdFusion Web applications can contain XML, HTML, and other client technologies such as CSS and JavaScript.
-
ColdFusion Features and Components 5 ColdFusion Features and Components ColdFusion provides a comprehensive set of features and components for developing and managing your Web applications. Using the ColdFusion components, you can enhance the speed and ease of development, dynamically deploy your applications, integrate new and legacy technologies, and build secure applications.
-
6 Chapter 1 Introduction to ColdFusion Benefits Features Open integration • Database connectivity using native database drivers (Enterprise Edition only), ODBC, or OLE DB • Embedded support for full-text indexing and searching • Standards-based integration with directory, mail, HTTP, FTP, and file servers • Connectivity to distributed object technologies, including CORBA (Enterprise Edition only), COM (Windows Enterprise Edition only), Java objects and EJBs • Open extensibility with C/C++ and Java Secur
-
ColdFusion Features and Components 7 data input and format data output. They can contain ColdFusion (CFML) tags, HTML tags, CFScript, JavaScript, and anything else that you can normally embed in an ordinary HTML page. You can easily access data sources, such as relational databases, from your application pages. The default file extension used for ColdFusion application pages is cfm.
-
8 Chapter 1 Introduction to ColdFusion How ColdFusion Server Works Regardless of which ColdFusion Server you have installed, ColdFusion application pages are processed on the server at runtime, each time they are requested by a browser. A page request happens when you click a Web site link to open a Web page in your browser.
-
Chapter 2 Writing Your First ColdFusion Application This chapter guides you through the ColdFusion development process as you create a ColdFusion application page, save it, and view it in a browser. Contents • The Development Process........................................................................................ 10 • Working with ColdFusion Application Pages.......................................................... 10 • Working with Variables ......................................................
-
10 Chapter 2 Writing Your First ColdFusion Application The Development Process Whether you are creating a static HTML page or a ColdFusion application page, you follow the same iterative process: 1 Write some code. 2 Save the code to a document or page. 3 View the page in a browser. 4 Modify the page. 5 Save the page again. 6 View it in a browser.
-
Working with ColdFusion Application Pages 11 I’d like to talk to someone in #Department#.