MACROMEDIA COLDFUSION MX 61-CFML Informations techniques

Naviguer en ligne ou télécharger Informations techniques pour Logiciel MACROMEDIA COLDFUSION MX 61-CFML. MACROMEDIA COLDFUSION MX 61-CFML System information Manuel d'utilisatio

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 152
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs

Résumé du contenu

Page 1 - COLDFUSION

COLDFUSION®MX 7Getting Started Building ColdFusion MX Applications

Page 3 - CONTENTS

100 Chapter 9: Lesson 6: Creating a Main Application PageReviewing the code The following table describes the navigation code for the Trip Detail pag

Page 4

Summary 101To test the updated application:1.Open your browser.2.Enter the following URL to view the updated tripdetail.cfm pagehttp://localhost/cfdoc

Page 5 - Contents 5

102 Chapter 9: Lesson 6: Creating a Main Application Page

Page 6 - 6 Contents

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

Page 7 - INTRODUCTION

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

Page 8 - 8 Introduction:

Exercise 1: Using an HTML form to collect data 105<td><select size="1" name="eventType"><option value="1"

Page 9 - Welcome to ColdFusion

106 Chapter 10: Lesson 7: Validating Data to Enforce Business Rules <TR> <TD valign="top">Photo File Name</TD> &

Page 10

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

Page 11 - Introducing ColdFusion MX

108 Chapter 10: Lesson 7: Validating Data to Enforce Business RulesExercise 3: About data validationTo ensure that the data entered in the trip edit

Page 12 - • ColdFusion data sources

Exercise 4: Providing server-side validation 109Exercise 4: Providing server-side validationIn this exercise, you will learn about the following tasks

Page 13

11CHAPTER 1Introducing ColdFusion MXThis chapter introduces the core technologies that are the foundation for Macromedia ColdFusion MX. In addition, i

Page 14

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

Page 15 - CFML Basics

Exercise 4: Providing server-side validation 111Evaluating check box and radio button variablesBusiness rule 8 in the Compass Travel new trip policy r

Page 16 - 16 Chapter 2: CFML Basics

112 Chapter 10: Lesson 7: Validating Data to Enforce Business RulesNote: You have already entered validation code for business rule 1. Validation cod

Page 17 - To view the ColdFusion page:

Exercise 4: Providing server-side validation 113Note: The code for business rules 7 and 8 uses ColdFusion cfif and cfelse conditional processing tags.

Page 18 - About CFML elements

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

Page 19 - Tag attributes

Exercise 5: Validating data on the client using ColdFusion form tags 115ColdFusion form tags include the following attributes:To use the improved form

Page 20 - Functions and parentheses

116 Chapter 10: Lesson 7: Validating Data to Enforce Business RulesModifying the Trip Edit page to use ColdFusion form tagsIn this exercise, you use

Page 21 - Nesting functions

Exercise 5: Validating data on the client using ColdFusion form tags 117Tip: For additional help, review the completed code in the ttripedit_lesson7_e

Page 22 - 22 Chapter 2: CFML Basics

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

Page 23

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

Page 24 - 24 Chapter 2: CFML Basics

12 Chapter 1: Introducing ColdFusion MXThe ColdFusion Markup LanguageColdFusion Markup Language (CFML) is a tag-based language similar to HTML that u

Page 25

120 Chapter 10: Lesson 7: Validating Data to Enforce Business Rules4.Replace the following eventtypes code lines:<cfselect size="1" name

Page 26 - Arithmetic operators

Exercise 7: Validating the existence of the trip photo file 121For more information about the FileExists function, see CFML Reference.To verify that t

Page 27 - About conditional processing

122 Chapter 10: Lesson 7: Validating Data to Enforce Business RulesReviewing the codeThe following table describes the code used to verify whether th

Page 28 - Processing form data

123CHAPTER 11Lesson 8: Implementing Browsing and Searching In this lesson, you will further enhance the Compass Travel Macromedia ColdFusion applicati

Page 29

124 Chapter 11: Lesson 8: Implementing Browsing and SearchingUsing dynamic SQL to browse the Trips tableThe tripID uniquely identifies a trip in the

Page 30 - Commenting your code

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

Page 31 - Database Fundamentals

126 Chapter 11: Lesson 8: Implementing Browsing and SearchingReviewing the codeThe following table describes the code used to process the navigation

Page 32 - Field (column)

Exercise 3: Enabling searching from the Trip Detail page 127Exercise 2: Determining actions based on which button a user clicksIn “Lesson 6: Creating

Page 33 - About database basics 33

128 Chapter 11: Lesson 8: Implementing Browsing and SearchingReviewing the codeThe following table describes the code that executes when the user cli

Page 34 - About SQL

129CHAPTER 12Lesson 9: Enabling Database MaintenanceIn this lesson, you will enable maintenance of the trips database. The exercises will guide you th

Page 35 - About SQL 35

Building applications with CFML 13Building applications with CFMLYou build ColdFusion applications as a series of pages that use CFML. Developers can

Page 36 - Using SQL with ColdFusion

130 Chapter 12: Lesson 9: Enabling Database MaintenanceThe SQL DELETE statement removes existing rows in a relational table. The DELETE statement has

Page 37 - Using SQL with ColdFusion 37

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

Page 38

132 Chapter 12: Lesson 9: Enabling Database MaintenanceFor example, the database table named Clients contains information about people in the followi

Page 39

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

Page 40

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

Page 41 - Sample Application

Exercise 3: Adding data using the cfinsert tag 135Reviewing the codeThe following table describes the SQL INSERT and cfquery code that ColdFusion uses

Page 42

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

Page 43

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

Page 44 - Recognizing the data types

138 Chapter 12: Lesson 9: Enabling Database MaintenanceReviewing the codeThe following tables describes the cfinsert and cfupdate code:To update the

Page 45

Exercise 6: Inserting values in the edit form 1393.Insert the highlighted code:<cfelseif IsDefined("Form.btnEdit")><!--- Code to ex

Page 46

14 Chapter 1: Introducing ColdFusion MX

Page 47

140 Chapter 12: Lesson 9: Enabling Database Maintenance<cfset tripDescription = ''><cfset eventTypeIdentifier = #GetEvents.eventTy

Page 48

Exercise 6: Inserting values in the edit form 141<TD><cfinput name="departureDate" size="10"required="Yes" vali

Page 49 - Development Environment

142 Chapter 12: Lesson 9: Enabling Database MaintenanceReviewing the codeThe following table describes the code that ColdFusion uses to properly init

Page 50

143CHAPTER 13Lesson 10: Restricting Access to ColdFusion ApplicationsThis chapter provides information on using the Login Wizard to restrict access to

Page 51

144 Chapter 13: Lesson 10: Restricting Access to ColdFusion ApplicationsPreparing to run the Login WizardBefore using the Login Wizard, you should de

Page 52

Exercise 1: About the Login Wizard 145Adding user authentication to an existing applicationYou can use the Login Wizard to add user authentication to

Page 53

146 Chapter 13: Lesson 10: Restricting Access to ColdFusion ApplicationsCreating a login using simple authenticationWhen you create a Login using sim

Page 54

Exercise 2: Requiring users to log in to the Compass Travel application 147Creating a login using Windows NT authentication1.Start the Login Wizard. (

Page 55

148 Chapter 13: Lesson 10: Restricting Access to ColdFusion ApplicationsTo test the authentication:1.Open the tripdetail.cfm page in the my_app direc

Page 56 - The application form

149INDEXAaction pagescreating 107defined 28actions based on buttons 127addingdatabase maintenance buttons 100navigation buttons 98rows to a table

Page 57 - Summary 57

15CHAPTER 2CFML Basics This chapter introduces the basic elements of CFML, including how to create Macromedia ColdFusion pages, and use variables, fun

Page 58

150 Indexconditional processing 27, 28, 76, 82contains operator 73context root 17creatingaction pages 107CFCs 64cross-field edits 108currency

Page 59 - Lesson 3: Retrieving Data

Index 151Ggreater than operator 73HHTML forms 73Iinserting, values in forms 139invoking methods 65, 68IsDefined function 85JJ2EE configuration

Page 60

152 IndexSQLAND operator 75commands 34data source 36described 34, 37dynamic 75, 124INSERT statement 131ORDER BY statement 36security risks 9

Page 61

16 Chapter 2: CFML BasicsThe best choice for creating ColdFusion pages is Macromedia Dreamweaver MX. Dreamweaver MX includes many CFML features for b

Page 62

Working with ColdFusion pages 17Saving your ColdFusion pageIn order for the ColdFusion server to process the page, you must save the ColdFusion page o

Page 63

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

Page 64

About CFML elements 19Most often the end tag encloses the tag name in brackets and includes a forward slash (/), like this:</tagname>The informa

Page 65

Trademarks1 Step RoboPDF, ActiveEdit, ActiveTest, Authorware, Blue Sky Software, Blue Sky, Breeze, Breezo, Captivate, Central, ColdFusion, Contribute,

Page 66

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

Page 67

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

Page 68

22 Chapter 2: CFML BasicsIn the following examples, the variables are assigned a string literal value. All string literal values are surrounded by do

Page 69 - Summary 69

Working with CFML expressions 23Displaying variable outputOutput is what remains after the ColdFusion server processes the CFML tags on a page. Usuall

Page 70

24 Chapter 2: CFML BasicsBuilding expressionsIn ColdFusion, you build expressions as you need them. The expressions can include simple elements, such

Page 71 - CHAPTER 7

Working with CFML expressions 25For more information and examples on using number signs in expressions, see ColdFusion MX Developer’s Guide.Specifying

Page 72

26 Chapter 2: CFML BasicsThe following table lists the unsupported logical operators and their equivalent ColdFusion operators:Arithmetic operatorsTh

Page 73 - • Price greater than 1500

About conditional processing 27String operatorThe following table describes the one ColdFusion string operator that is a concatenation operator:About

Page 74

28 Chapter 2: CFML BasicsUsing the cfelseif tag to evaluate multiple expressionsTo evaluate multiple expressions in a cfif statement, you can use cfe

Page 75

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

Page 76 - ■ The SQL keyword AND

3CONTENTSINTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7PART I: Welcome to Cold

Page 77

30 Chapter 2: CFML BasicsCommenting your codeAs in other programming languages, it is important to include comments in your code. You should comment

Page 78

31CHAPTER 3Database Fundamentals This chapter provides a quick overview of relational database concepts and terms. It describes what a database is and

Page 79

32 Chapter 3: Database FundamentalsWhat is a relational database?A relational database is a structured collection of information that is related to a

Page 80

About database basics 33About relational tablesIn a database, you can organize data in multiple tables. For example, if you manage a database for the

Page 81

34 Chapter 3: Database FundamentalsAbout SQLSQL (Structured Query Language) is a language that lets you communicate with databases. For example, you

Page 82 - Search form

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

Page 83 - Summary 83

36 Chapter 3: Database FundamentalsThe result of the preceding SQL statement contains the following data:Note: The preceding SQL SELECT examples use

Page 84

Using SQL with ColdFusion 37Writing SQL and CFML statements to interact with a data sourceAfter ColdFusion makes a connection to the data source, you

Page 85 - CHAPTER 8

38 Chapter 3: Database Fundamentals

Page 86

PART IIBuilding a ColdFusion ApplicationPart II provides a tutorial that steps you through building a sample Macromedia ColdFusion application. It con

Page 87

4 ContentsCHAPTER 5: Lesson 2: Configuring Your Development Environment. . . . . . . . . 49Exercise 1: Verifying the tutorial file structure . . . .

Page 89

41CHAPTER 4Lesson 1: Preparing to Build the Sample ApplicationThis tutorial guides you through the process of building a simple Macromedia ColdFusion

Page 90

42 Chapter 4: Lesson 1: Preparing to Build the Sample ApplicationThe following sections explore an overview of each of these application development

Page 91

Exercise 3: Designing the database for your application 43Exercise 2: Determining the data requirementsPrior to creating the application pages to capt

Page 92 - Detail page

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

Page 93 - Trip Detail pages

Exercise 3: Designing the database for your application 45Establishing a relationship between the two tablesWhen the user selects an event type from t

Page 94

46 Chapter 4: Lesson 1: Preparing to Build the Sample ApplicationExercise 4: Developing the sample applicationUsing the application functional requir

Page 95 - Summary 95

Exercise 4: Developing the sample application 47• Implement browsing and searching (“Lesson 8: Implementing Browsing and Searching” on page 123).• Ena

Page 96

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

Page 97 - CHAPTER 9

49CHAPTER 5Lesson 2: Configuring Your Development EnvironmentIn this lesson, you set up your development environment for the tutorial. This lesson des

Page 98

Contents 5CHAPTER 11: Lesson 8: Implementing Browsing and Searching . . . . . . . . . . . . 123Exercise 1: Enabling users to browse trip details . .

Page 99

50 Chapter 5: Lesson 2: Configuring Your Development EnvironmentNote: When you use the J2EE configuration, the cfdocs directory is under the ColdFusi

Page 100 - Reviewing the code

Exercise 2: Setting up your development environment 51With Dreamweaver MX, you can author and test your application code from a local or remote client

Page 101 - Summary 101

52 Chapter 5: Lesson 2: Configuring Your Development EnvironmentExercise 3: Configuring a database connectionOne of the most commonly used and most p

Page 102

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

Page 103 - Business Rules

54 Chapter 5: Lesson 2: Configuring Your Development EnvironmentTo define the sample PointBase database file: 1.In the ColdFusion MX Administrator, s

Page 104

Exercise 4: Configuring debugging options 557.Click Verify All Connections to ensure that ColdFusion can access this file. OK appears in the Status co

Page 105

56 Chapter 5: Lesson 2: Configuring Your Development EnvironmentThe location of the debugging information or the type of debugging data shown varies,

Page 106

Summary 57Sending debugging information to remote clientsIf you are using a remote client to perform the tutorial in this book, you must specify your

Page 107

58 Chapter 5: Lesson 2: Configuring Your Development Environment

Page 108

59CHAPTER 6Lesson 3: Retrieving Data In this lesson, you begin the construction of a Macromedia ColdFusion web application for the fictitious company,

Page 109

6 Contents

Page 110

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

Page 111

Exercise 2: Retrieving the information for the trip list 61Exercise 2: Retrieving the information for the trip listRelational database management syst

Page 112

62 Chapter 6: Lesson 3: Retrieving DataReviewing the codeThe following table describes the code used to build the query:Exercise 3: Displaying the qu

Page 113

Exercise 4: Writing structured, reusable code 63<body><h1>Trip List</h1><cfoutput query="TripList">#tripName#<br&

Page 114 - To test the validation code:

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

Page 115

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

Page 116

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

Page 117

Exercise 5: Creating additional queries 67output="false"><cfquery name="budgetTrips" datasource="CompassTravel">

Page 118

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

Page 119

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

Page 120

7INTRODUCTIONGetting Started Building ColdFusion MX Applications is intended for anyone who needs to begin programming in the Macromedia ColdFusion MX

Page 121 - ■ For MS Windows systems:

70 Chapter 6: Lesson 3: Retrieving Data

Page 122

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

Page 123 - CHAPTER 11

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

Page 124

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

Page 125

74 Chapter 7: Lesson 4: Building Dynamic Queries<title>Trip Maintenance - Search Form</title></head><body><img src="i

Page 126

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

Page 127

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

Page 128

Exercise 2: Building a query that uses dynamic SQL 77<cfset WhereClause = WhereClause & " AND tripLocation like '" &form.tri

Page 129 - CHAPTER 12

78 Chapter 7: Lesson 4: Building Dynamic Queries</cfquery><cfreturn TripResult></cffunction>4.Add the highlighted code to the cfque

Page 130

Exercise 3: Constructing the initial Trip Search Results page 79Exercise 3: Constructing the initial Trip Search Results pageAfter the user enters the

Page 131 - VALUES (value1, value2,...)

8 Introduction: Viewing online documentationAll ColdFusion MX documentation is available online in HTML and Adobe Acrobat Portable Document Format (P

Page 132

80 Chapter 7: Lesson 4: Building Dynamic Queries</td></tr><cfoutput query="TripResult"><tr> <td>#tripName#&l

Page 133 - Save the file

Exercise 4: Testing the Trip Search Results page 81The preceding code only builds the tripLocation subclause. In the following exercise, you will add

Page 134

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

Page 135

Summary 834.To build the price WHERE subclause, enter the following code after the code you entered in the previous step.<!--- Build subclause for

Page 136

84 Chapter 7: Lesson 4: Building Dynamic Queries

Page 137

85CHAPTER 8Lesson 5: Creating a Trip Detail PageIn this lesson you will enhance the Compass Travel Trip Maintenance application. This lesson contains

Page 138

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

Page 139

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

Page 140

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

Page 141

Exercise 1: Creating a Trip Detail page 89<tr><td valign="top">Return Date:</td><td>#returnDate#</td></tr&g

Page 142

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

Page 143 - ColdFusion Applications

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

Page 144 - <cfinclude

Exercise 2: Avoiding the potential security risk when using dynamic SQL 91Reviewing the codeThe following table describes the ColdFusion code that you

Page 145 - Access must be RDS

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

Page 146

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

Page 147

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

Page 148 - To test the authentication:

Summary 95SummaryIn this lesson, you transformed the search facility that you built in “Lesson 4: Building Dynamic Queries” into a drill-down facility

Page 149

96 Chapter 8: Lesson 5: Creating a Trip Detail Page

Page 150 - 150 Index

97CHAPTER 9Lesson 6: Creating a Main Application PageIn this lesson you will enhance the Compass Travel Trip Maintenance application. So far, you crea

Page 151 - Index 151

98 Chapter 9: Lesson 6: Creating a Main Application PageExercise 1: Creating the main application page from the Trip Detail pageIn this exercise, you

Page 152 - 152 Index

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

Commentaires sur ces manuels

Pas de commentaire