COLDFUSION®MX 7Getting Started Building ColdFusion MX Applications
100 Chapter 9: Lesson 6: Creating a Main Application PageReviewing the code The following table describes the navigation code for the Trip Detail pag
Summary 101To test the updated application:1.Open your browser.2.Enter the following URL to view the updated tripdetail.cfm pagehttp://localhost/cfdoc
102 Chapter 9: Lesson 6: Creating a Main Application Page
103CHAPTER 10Lesson 7: Validating Data to Enforce Business RulesIn this lesson, you will create a page for the trip coordinator to add new trip offeri
104 Chapter 10: Lesson 7: Validating Data to Enforce Business RulesExercise 1: Using an HTML form to collect dataIn this exercise, you develop the Tr
Exercise 1: Using an HTML form to collect data 105<td><select size="1" name="eventType"><option value="1"
106 Chapter 10: Lesson 7: Validating Data to Enforce Business Rules <TR> <TD valign="top">Photo File Name</TD> &
Exercise 2: Creating a simple action page 107At this point, this form does not store any information in the database and does not enforce any business
108 Chapter 10: Lesson 7: Validating Data to Enforce Business RulesExercise 3: About data validationTo ensure that the data entered in the trip edit
Exercise 4: Providing server-side validation 109Exercise 4: Providing server-side validationIn this exercise, you will learn about the following tasks
11CHAPTER 1Introducing ColdFusion MXThis chapter introduces the core technologies that are the foundation for Macromedia ColdFusion MX. In addition, i
110 Chapter 10: Lesson 7: Validating Data to Enforce Business RulesBecause you did not yet add any logic to test whether any values entered in the fo
Exercise 4: Providing server-side validation 111Evaluating check box and radio button variablesBusiness rule 8 in the Compass Travel new trip policy r
112 Chapter 10: Lesson 7: Validating Data to Enforce Business RulesNote: You have already entered validation code for business rule 1. Validation cod
Exercise 4: Providing server-side validation 113Note: The code for business rules 7 and 8 uses ColdFusion cfif and cfelse conditional processing tags.
114 Chapter 10: Lesson 7: Validating Data to Enforce Business RulesTo test the validation code:1.View the tripedit.cfm page in the browser. 2.In the
Exercise 5: Validating data on the client using ColdFusion form tags 115ColdFusion form tags include the following attributes:To use the improved form
116 Chapter 10: Lesson 7: Validating Data to Enforce Business RulesModifying the Trip Edit page to use ColdFusion form tagsIn this exercise, you use
Exercise 5: Validating data on the client using ColdFusion form tags 117Tip: For additional help, review the completed code in the ttripedit_lesson7_e
118 Chapter 10: Lesson 7: Validating Data to Enforce Business Rules5.Open the tripeditaction.cfm file in the my_app directory and delete the code for
Exercise 6: Dynamically populating the list of event types 119To test the modified code:1.View the tripedit.cfm page in a browser.2.Test the client- a
12 Chapter 1: Introducing ColdFusion MXThe ColdFusion Markup LanguageColdFusion Markup Language (CFML) is a tag-based language similar to HTML that u
120 Chapter 10: Lesson 7: Validating Data to Enforce Business Rules4.Replace the following eventtypes code lines:<cfselect size="1" name
Exercise 7: Validating the existence of the trip photo file 121For more information about the FileExists function, see CFML Reference.To verify that t
122 Chapter 10: Lesson 7: Validating Data to Enforce Business RulesReviewing the codeThe following table describes the code used to verify whether th
123CHAPTER 11Lesson 8: Implementing Browsing and Searching In this lesson, you will further enhance the Compass Travel Macromedia ColdFusion applicati
124 Chapter 11: Lesson 8: Implementing Browsing and SearchingUsing dynamic SQL to browse the Trips tableThe tripID uniquely identifies a trip in the
Exercise 1: Enabling users to browse trip details 125Limiting the number of result rowsEach of the SQL statements in the preceding table returns a res
126 Chapter 11: Lesson 8: Implementing Browsing and SearchingReviewing the codeThe following table describes the code used to process the navigation
Exercise 3: Enabling searching from the Trip Detail page 127Exercise 2: Determining actions based on which button a user clicksIn “Lesson 6: Creating
128 Chapter 11: Lesson 8: Implementing Browsing and SearchingReviewing the codeThe following table describes the code that executes when the user cli
129CHAPTER 12Lesson 9: Enabling Database MaintenanceIn this lesson, you will enable maintenance of the trips database. The exercises will guide you th
Building applications with CFML 13Building applications with CFMLYou build ColdFusion applications as a series of pages that use CFML. Developers can
130 Chapter 12: Lesson 9: Enabling Database MaintenanceThe SQL DELETE statement removes existing rows in a relational table. The DELETE statement has
Exercise 2: Adding trips with SQL INSERT statements 131To test the delete capability:1.View the tripdetail.cfm page in a browser. The current trip is
132 Chapter 12: Lesson 9: Enabling Database MaintenanceFor example, the database table named Clients contains information about people in the followi
Exercise 2: Adding trips with SQL INSERT statements 133To add data using a SQL INSERT statement and a cfquery tag:1.Open the tripeditaction.cfm file i
134 Chapter 12: Lesson 9: Enabling Database MaintenanceTo test the modified code:1.Open the tripedit.cfm page in your browser.2.In the tripedit.cfm p
Exercise 3: Adding data using the cfinsert tag 135Reviewing the codeThe following table describes the SQL INSERT and cfquery code that ColdFusion uses
136 Chapter 12: Lesson 9: Enabling Database MaintenanceTo add data using cfinsert:1.Open the tripeditaction.cfm file from the my_app directory in you
Exercise 4: Updating a SQL row using the cfupdate tag 1373.To verify that the trip was saved, open the tripsearchform.cfm page in the my_app directory
138 Chapter 12: Lesson 9: Enabling Database MaintenanceReviewing the codeThe following tables describes the cfinsert and cfupdate code:To update the
Exercise 6: Inserting values in the edit form 1393.Insert the highlighted code:<cfelseif IsDefined("Form.btnEdit")><!--- Code to ex
14 Chapter 1: Introducing ColdFusion MX
140 Chapter 12: Lesson 9: Enabling Database Maintenance<cfset tripDescription = ''><cfset eventTypeIdentifier = #GetEvents.eventTy
Exercise 6: Inserting values in the edit form 141<TD><cfinput name="departureDate" size="10"required="Yes" vali
142 Chapter 12: Lesson 9: Enabling Database MaintenanceReviewing the codeThe following table describes the code that ColdFusion uses to properly init
143CHAPTER 13Lesson 10: Restricting Access to ColdFusion ApplicationsThis chapter provides information on using the Login Wizard to restrict access to
144 Chapter 13: Lesson 10: Restricting Access to ColdFusion ApplicationsPreparing to run the Login WizardBefore using the Login Wizard, you should de
Exercise 1: About the Login Wizard 145Adding user authentication to an existing applicationYou can use the Login Wizard to add user authentication to
146 Chapter 13: Lesson 10: Restricting Access to ColdFusion ApplicationsCreating a login using simple authenticationWhen you create a Login using sim
Exercise 2: Requiring users to log in to the Compass Travel application 147Creating a login using Windows NT authentication1.Start the Login Wizard. (
148 Chapter 13: Lesson 10: Restricting Access to ColdFusion ApplicationsTo test the authentication:1.Open the tripdetail.cfm page in the my_app direc
149INDEXAaction pagescreating 107defined 28actions based on buttons 127addingdatabase maintenance buttons 100navigation buttons 98rows to a table
15CHAPTER 2CFML Basics This chapter introduces the basic elements of CFML, including how to create Macromedia ColdFusion pages, and use variables, fun
150 Indexconditional processing 27, 28, 76, 82contains operator 73context root 17creatingaction pages 107CFCs 64cross-field edits 108currency
Index 151Ggreater than operator 73HHTML forms 73Iinserting, values in forms 139invoking methods 65, 68IsDefined function 85JJ2EE configuration
152 IndexSQLAND operator 75commands 34data source 36described 34, 37dynamic 75, 124INSERT statement 131ORDER BY statement 36security risks 9
16 Chapter 2: CFML BasicsThe best choice for creating ColdFusion pages is Macromedia Dreamweaver MX. Dreamweaver MX includes many CFML features for b
Working with ColdFusion pages 17Saving your ColdFusion pageIn order for the ColdFusion server to process the page, you must save the ColdFusion page o
18 Chapter 2: CFML BasicsThe following figure shows the cfpage.cfm page in the browser:2.Do the following tasks:aView the source code that was return
About CFML elements 19Most often the end tag encloses the tag name in brackets and includes a forward slash (/), like this:</tagname>The informa
Trademarks1 Step RoboPDF, ActiveEdit, ActiveTest, Authorware, Blue Sky Software, Blue Sky, Breeze, Breezo, Captivate, Central, ColdFusion, Contribute,
20 Chapter 2: CFML BasicsFunctions and number signsYou use number signs (#) with functions to display the results of a function on the page. Number s
About CFML elements 21Using functions on valuesUsually, a function performs an operation on a value, and the value can include the value of a variable
22 Chapter 2: CFML BasicsIn the following examples, the variables are assigned a string literal value. All string literal values are surrounded by do
Working with CFML expressions 23Displaying variable outputOutput is what remains after the ColdFusion server processes the CFML tags on a page. Usuall
24 Chapter 2: CFML BasicsBuilding expressionsIn ColdFusion, you build expressions as you need them. The expressions can include simple elements, such
Working with CFML expressions 25For more information and examples on using number signs in expressions, see ColdFusion MX Developer’s Guide.Specifying
26 Chapter 2: CFML BasicsThe following table lists the unsupported logical operators and their equivalent ColdFusion operators:Arithmetic operatorsTh
About conditional processing 27String operatorThe following table describes the one ColdFusion string operator that is a concatenation operator:About
28 Chapter 2: CFML BasicsUsing the cfelseif tag to evaluate multiple expressionsTo evaluate multiple expressions in a cfif statement, you can use cfe
Processing form data 29When a user submits a form, the form values are stored in form variables and sent to the action page for processing. The follow
3CONTENTSINTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7PART I: Welcome to Cold
30 Chapter 2: CFML BasicsCommenting your codeAs in other programming languages, it is important to include comments in your code. You should comment
31CHAPTER 3Database Fundamentals This chapter provides a quick overview of relational database concepts and terms. It describes what a database is and
32 Chapter 3: Database FundamentalsWhat is a relational database?A relational database is a structured collection of information that is related to a
About database basics 33About relational tablesIn a database, you can organize data in multiple tables. For example, if you manage a database for the
34 Chapter 3: Database FundamentalsAbout SQLSQL (Structured Query Language) is a language that lets you communicate with databases. For example, you
About SQL 35Using the SQL WHERE clause to limit the rows returnedTo conditionally select data from a table, you can add a WHERE clause to the SELECT s
36 Chapter 3: Database FundamentalsThe result of the preceding SQL statement contains the following data:Note: The preceding SQL SELECT examples use
Using SQL with ColdFusion 37Writing SQL and CFML statements to interact with a data sourceAfter ColdFusion makes a connection to the data source, you
38 Chapter 3: Database Fundamentals
PART IIBuilding a ColdFusion ApplicationPart II provides a tutorial that steps you through building a sample Macromedia ColdFusion application. It con
4 ContentsCHAPTER 5: Lesson 2: Configuring Your Development Environment. . . . . . . . . 49Exercise 1: Verifying the tutorial file structure . . . .
41CHAPTER 4Lesson 1: Preparing to Build the Sample ApplicationThis tutorial guides you through the process of building a simple Macromedia ColdFusion
42 Chapter 4: Lesson 1: Preparing to Build the Sample ApplicationThe following sections explore an overview of each of these application development
Exercise 3: Designing the database for your application 43Exercise 2: Determining the data requirementsPrior to creating the application pages to capt
44 Chapter 4: Lesson 1: Preparing to Build the Sample ApplicationIf you had to create the Compass Travel database, you would create a table named tri
Exercise 3: Designing the database for your application 45Establishing a relationship between the two tablesWhen the user selects an event type from t
46 Chapter 4: Lesson 1: Preparing to Build the Sample ApplicationExercise 4: Developing the sample applicationUsing the application functional requir
Exercise 4: Developing the sample application 47• Implement browsing and searching (“Lesson 8: Implementing Browsing and Searching” on page 123).• Ena
48 Chapter 4: Lesson 1: Preparing to Build the Sample ApplicationYou can view ColdFusion application pages on your local computer by opening a web br
49CHAPTER 5Lesson 2: Configuring Your Development EnvironmentIn this lesson, you set up your development environment for the tutorial. This lesson des
Contents 5CHAPTER 11: Lesson 8: Implementing Browsing and Searching . . . . . . . . . . . . 123Exercise 1: Enabling users to browse trip details . .
50 Chapter 5: Lesson 2: Configuring Your Development EnvironmentNote: When you use the J2EE configuration, the cfdocs directory is under the ColdFusi
Exercise 2: Setting up your development environment 51With Dreamweaver MX, you can author and test your application code from a local or remote client
52 Chapter 5: Lesson 2: Configuring Your Development EnvironmentExercise 3: Configuring a database connectionOne of the most commonly used and most p
Exercise 3: Configuring a database connection 53To access the ColdFusion MX 7 Administrator:• Open a browser and go to one of the following URLs: Ext
54 Chapter 5: Lesson 2: Configuring Your Development EnvironmentTo define the sample PointBase database file: 1.In the ColdFusion MX Administrator, s
Exercise 4: Configuring debugging options 557.Click Verify All Connections to ensure that ColdFusion can access this file. OK appears in the Status co
56 Chapter 5: Lesson 2: Configuring Your Development EnvironmentThe location of the debugging information or the type of debugging data shown varies,
Summary 57Sending debugging information to remote clientsIf you are using a remote client to perform the tutorial in this book, you must specify your
58 Chapter 5: Lesson 2: Configuring Your Development Environment
59CHAPTER 6Lesson 3: Retrieving Data In this lesson, you begin the construction of a Macromedia ColdFusion web application for the fictitious company,
6 Contents
60 Chapter 6: Lesson 3: Retrieving DataExercise 1: About the trip listAs you recall from “Lesson 1: Preparing to Build the Sample Application” on pag
Exercise 2: Retrieving the information for the trip list 61Exercise 2: Retrieving the information for the trip listRelational database management syst
62 Chapter 6: Lesson 3: Retrieving DataReviewing the codeThe following table describes the code used to build the query:Exercise 3: Displaying the qu
Exercise 4: Writing structured, reusable code 63<body><h1>Trip List</h1><cfoutput query="TripList">#tripName#<br&
64 Chapter 6: Lesson 3: Retrieving DataTo create the CFC file:1.Create a directory named components as a subdirectory of the my_app directory.2.Open
Exercise 4: Writing structured, reusable code 65Copying the query to the CFCTo copy the query to the CFC, you copy the CFML to the CFC, between the op
66 Chapter 6: Lesson 3: Retrieving DataLet Dreamweaver do itDreamweaver lets you invoke a method in a CFC without having to write the code.To invoke
Exercise 5: Creating additional queries 67output="false"><cfquery name="budgetTrips" datasource="CompassTravel">
68 Chapter 6: Lesson 3: Retrieving DataInvoking the new methodTo use the new query, you invoke the method that contains the query.To invoke the new m
Summary 693.Save both the triplisting.cfm file and the gettrips.cfc file.4.View the triplisting.cfm page in a browser and verify that all the new requ
7INTRODUCTIONGetting Started Building ColdFusion MX Applications is intended for anyone who needs to begin programming in the Macromedia ColdFusion MX
70 Chapter 6: Lesson 3: Retrieving Data
71CHAPTER 7Lesson 4: Building Dynamic Queries In this lesson, you develop a search form to allow users to select the information to retrieve, and then
72 Chapter 7: Lesson 4: Building Dynamic QueriesA better solution is to provide an interface for the user to specify the search criteria. The purpose
Exercise 1: Creating the trip search form 73In later exercises, you will reference these columns when you build the SQL SELECT statement for the cfque
74 Chapter 7: Lesson 4: Building Dynamic Queries<title>Trip Maintenance - Search Form</title></head><body><img src="i
Exercise 2: Building a query that uses dynamic SQL 75</form></body></html>3.Save the file as tripsearchform.cfm in the my_app direct
76 Chapter 7: Lesson 4: Building Dynamic QueriesThe action page invokes a method that builds the WHERE clause so that the SQL SELECT statement retrie
Exercise 2: Building a query that uses dynamic SQL 77<cfset WhereClause = WhereClause & " AND tripLocation like '" &form.tri
78 Chapter 7: Lesson 4: Building Dynamic Queries</cfquery><cfreturn TripResult></cffunction>4.Add the highlighted code to the cfque
Exercise 3: Constructing the initial Trip Search Results page 79Exercise 3: Constructing the initial Trip Search Results pageAfter the user enters the
8 Introduction: Viewing online documentationAll ColdFusion MX documentation is available online in HTML and Adobe Acrobat Portable Document Format (P
80 Chapter 7: Lesson 4: Building Dynamic Queries</td></tr><cfoutput query="TripResult"><tr> <td>#tripName#&l
Exercise 4: Testing the Trip Search Results page 81The preceding code only builds the tripLocation subclause. In the following exercise, you will add
82 Chapter 7: Lesson 4: Building Dynamic Queries3.Verify that the other criteria (departure date and price) are not taken into consideration yet as f
Summary 834.To build the price WHERE subclause, enter the following code after the code you entered in the previous step.<!--- Build subclause for
84 Chapter 7: Lesson 4: Building Dynamic Queries
85CHAPTER 8Lesson 5: Creating a Trip Detail PageIn this lesson you will enhance the Compass Travel Trip Maintenance application. This lesson contains
86 Chapter 8: Lesson 5: Creating a Trip Detail PageExercise 1: Creating a Trip Detail pageBy design, the Trip Search Results page displays a subset o
Exercise 1: Creating a Trip Detail page 87To build the CFC query:1.Create a blank ColdFusion page.2.Save the file as tripdetail.cfm in the my_app dire
88 Chapter 8: Lesson 5: Creating a Trip Detail Page12.In the Component Location text box, enter /components/.13.In the Recordset name text box, enter
Exercise 1: Creating a Trip Detail page 89<tr><td valign="top">Return Date:</td><td>#returnDate#</td></tr&g
PART IWelcome to ColdFusionPart I provides an introduction to Macromedia ColdFusion MX 7. It defines ColdFusion MX 7 and provides an overview of the C
90 Chapter 8: Lesson 5: Creating a Trip Detail Page4.Add the following code at the end of the file:</body></html>5.Save the file.To view
Exercise 2: Avoiding the potential security risk when using dynamic SQL 91Reviewing the codeThe following table describes the ColdFusion code that you
92 Chapter 8: Lesson 5: Creating a Trip Detail PageIf a user called the Trip Detail page using the following statement:http://localhost/cfdocs/gettin
Exercise 4: Enhancing the look of the Trip Search Results and Trip Detail pages 93To test the revised page:1.View the tripsearchform.cfm page from the
94 Chapter 8: Lesson 5: Creating a Trip Detail Page2.Save the file.3.To format the currency and date fields on the Trips Search Results page, open th
Summary 95SummaryIn this lesson, you transformed the search facility that you built in “Lesson 4: Building Dynamic Queries” into a drill-down facility
96 Chapter 8: Lesson 5: Creating a Trip Detail Page
97CHAPTER 9Lesson 6: Creating a Main Application PageIn this lesson you will enhance the Compass Travel Trip Maintenance application. So far, you crea
98 Chapter 9: Lesson 6: Creating a Main Application PageExercise 1: Creating the main application page from the Trip Detail pageIn this exercise, you
Exercise 1: Creating the main application page from the Trip Detail page 99To add navigation buttons to the Trip Detail page:1.Open the tripdetail.cfm
Kommentare zu diesen Handbüchern