450 likes | 580 Views
This chapter provides an in-depth overview of Macromedia ColdFusion MX, covering the essentials of creating dynamic web applications. Learn how to create basic ColdFusion templates, utilize CFML tags and functions for dynamic content, and process user inputs from web forms. Through a practical bookstore case study, you will explore interfaces, database interactions, and implement a shopping cart that tracks user selections. This lesson also discusses advanced topics for ColdFusion developers, including custom tags and working with XML and web services.
E N D
Chapter 27 – Macromedia ColdFusion MX Outline 27.1 Introduction 27.2 Simple ColdFusion Example: Clock 27.3 Using Variables and Expressions 27.4 Variable Scoping 27.5 Form Processing 27.6 Creating a Data Source Name 27.7 Bookstore Case Study: Interface and Database 27.8 Bookstore Case Study: Shopping Cart 27.9 Advanced Topics for ColdFusion Developers 27.10 Web Resources
Objectives • In this lesson, you will learn: • To create basic ColdFusion templates. • To use ColdFusion Markup Language tags and functions to add dynamic functionality to Web pages. • To use information collected from Web forms. • To create a database-driven bookstore application. • To create a shopping cart for the bookstore that follows a user through the site.
27.1 Introduction • ColdFusion • Widely used server-side markup language • Developed by Allaire • ColdFusion Markup Language (CFML) • Based around a set of tags that work like XHTML tags • Supports XML, ColdFusion Components and Web services • Saved with a .cfm extension • ColdFusion template
27.2 Simple ColdFusion Example: Clock • CFML comment • <!--- CFML Comment ---> • cfoutput tag • Variables and functions are enclosed in #’s • dateFormat • timeFormat • now
27.3 Using Variables and Expressions • CFML also supports creating and manipulating variables
27.3.1 Variables and Data Types • Variables much like variables in most other languages • cfset • Does not produce any output • No close tag
27.4 Variable Scoping • Scope • Defines from where the variable can be accessed • Refers to the named space where the variable is stored • cfif tag • Behaves just like if statements in other languages • cfelseif • cdelse • isDefined function • Returns true or false • NOT operator • Reverses the truth or falsity of entire expression
27.5 Form Processing • form variable scope • Gather information from the user • isNumeric function • Similar to isDefined function • Returns boolean value • Returns true if parameter is number • False otherwise
27.6 Creating a Data Source Name Fig. 27.10 Data source registration in the ColdFusion Administrator.
27.7 Bookstore Case Study: Interface and Database • cfquery tag • cflocation tag • Redirects the user to another CFML template • cfabort tag • Instructs CFML interpreter to stop and not finish processing page • cfloop tag • Outputs the code between its opening and closing tags once
27.8 Bookstore Case Study: Shopping Cart • cfapplication tag • Access the variable scopes related to applications • client variables • Can be stored as cookies on user’s computer or in server’s registery • session variables • Store contents of user’s shopping cart as user makes selections • application variables
27.9 Advanced Topics for ColdFusion Developers • Ability to create custom tags and user-defined functions • Set of built-in CFML tags for working with XML and for interacting with Web services
27.10 Web Resources • www.macromedia.com/software/coldfusion • www.macromedia.com/support/coldfusion/documentation.html • www.macromedia.com/cfusion/exchange/index.cfm?view=sn130 • www.forta.com • www.sys-con.com/coldfusion