Getting Started Building ColdFusion MX Applications
x About This BookViewing online documentationAll ColdFusion documentation is available online in HTML and Adobe Acrobat Portable Document Format (
90 Lesson 3 Creating a Main Application Page3 In the Trip Location drop-down list box, select Begins With and type the value C in the trip location
Enhancing the Trip Maintenance application 91The following example uses the MOD function to alternate the background color of table rows:<cfoutput
92 Lesson 3 Creating a Main Application Page2 To format the currency and date fields on the Trips Search Results page, open the tripsearchresult.cf
Enhancing the Trip Maintenance application 935 In the Trip Search Result page, click the link for Riding the Rockies. The properly formatted Trip Deta
94 Lesson 3 Creating a Main Application PageAdding navigation buttons to browse databaseThe drill-down search function developed in the last exerci
Enhancing the Trip Maintenance application 953 Save the file and view the updated tripdetail.cfm page in a browser.The Trip Search Results page appear
96 Lesson 3 Creating a Main Application PageAdding database maintenance buttonsThe search and sequential navigation capabilities are features for l
Enhancing the Trip Maintenance application 973 Save the file and view the updated tripdetail.cfm page in a browser (http://localhost/CFDOCS/getting_st
98 Lesson 3 Creating a Main Application PageSummaryIn this lesson, you transformed the search facility you built in Lesson 2 into a drill-down faci
99LESSON 4Validating Data to Enforce BusinessRulesIn this lesson, you will enhance the Compass Travel Trip Maintenance application. The exercises in t
PART IWelcome to ColdFusionPart I provides an introduction to ColdFusion. It defines ColdFusion and provides an overview of the ColdFusion Markup Lang
100 Lesson 4 Validating Data to Enforce Business RulesEnhancing the Trip Maintenance applicationIn this lesson and the next, you will create the co
Using an HTML form to collect data 101Using an HTML form to collect dataBased on the data requirements determined in Lesson 1, the following figure sh
102 Lesson 4 Validating Data to Enforce Business Rules3 Save the file as tripedit.cfm to the my_app directory.4 View the tripedit.cfm in a browser
Developing code to validate data and enforce business rules 103Developing code to validate data and enforce business rulesAs described in Lesson 1, it
104 Lesson 4 Validating Data to Enforce Business RulesValidating data using a server-side action pageThe first approach you will take to enforce Co
Developing code to validate data and enforce business rules 105The cfset tag lets you manipulate the value of a variable. For example, the following p
106 Lesson 4 Validating Data to Enforce Business Rules<!--- Price must be 20% greater than Base Cost ---><cfif Form.baseCost * 1.2 GT #Fo
Developing code to validate data and enforce business rules 107the network and the server. If the data is validated on the client, then only valid dat
108 Lesson 4 Validating Data to Enforce Business RulesClient-side validation approach using ColdFusion form tagThe following code is on the client:
Developing code to validate data and enforce business rules 109Tip: For additional help, review the completed code in the tripedit2.cfm within the sol
110 Lesson 4 Validating Data to Enforce Business Rules</body></html>7 View the tripedit.cfm page in a browser and test the client- and
Developing code to validate data and enforce business rules 111<!--- Field: eventType ---><tr><td valign="top">Type of Eve
112 Lesson 4 Validating Data to Enforce Business RulesUsing other client-side script to reduce edits on the serverIf you were interested in moving
Developing code to validate data and enforce business rules 113var testdate = new Date(dateString.substring(6,10),dateString.substring(0,2)-1,dateStri
114 Lesson 4 Validating Data to Enforce Business RulesThe important point about the preceding JavaScript is that you can use two functions, isitFut
Developing code to validate data and enforce business rules 115Validating the existence of the trip photo file At this point, you have a more efficien
116 Lesson 4 Validating Data to Enforce Business RulesReviewing the codeThe following table describes the code used to verify whether a file exists
Summary 1173 Save the page and test it by opening the tripedit.cfm page in your browser.Testing recommendations:a In the Trip Edit page entering valid
118 Lesson 4 Validating Data to Enforce Business Rules
119LESSON 5Implementing the Browsing andMaintenance Database FunctionsIn this lesson, you will enhance the Compass Travel ColdFusion application by pr
3CHAPTER 1Introducing ColdFusion MXThis chapter introduces the core technologies that are the foundation for Macromedia ColdFusion MX. It provides a b
120 Lesson 5 Implementing the Browsing and Maintenance Database FunctionsEnhancing the Trip Maintenance applicationIn this lesson, you will make en
Enhancing the Trip Maintenance application 121Maintenance action pageThe maintenance action page processes a user’s maintenance request from the Trip
122 Lesson 5 Implementing the Browsing and Maintenance Database FunctionsFor example, if the current tripID equals 6, the following table identifie
Enhancing the Trip Maintenance application 123<cfelseif IsDefined("Form.btnLast.X")>ORDER BY tripID DESC</cfif></cfquery>&
124 Lesson 5 Implementing the Browsing and Maintenance Database FunctionsExercise: implement trip record browsing (navigation)Follow these steps to
Enhancing the Trip Maintenance application 125<cfelseif IsDefined("Form.btnEdit")>...<cfelseif IsDefined("Form.btnAdd")&g
126 Lesson 5 Implementing the Browsing and Maintenance Database FunctionsDELETE FROM trips WHERE tripID = #Form.RecordID#Exercise: handle search an
Enhancing the Trip Maintenance application 1277In the Trip Search page, select begins with in the selection box for Trip Location. Then enter Imji in
128 Lesson 5 Implementing the Browsing and Maintenance Database FunctionsSummaryIn this lesson, you converted the Trip Detail page from the search
129LESSON 6Adding and Updating SQL DataIn this lesson, you will complete the Compass Travel Trip Maintenance application. The exercises will guide you
4 Chapter 1 Introducing ColdFusion MXThe Internet and related technologiesColdFusion MX is tightly integrated with the Internet and the World Wide
130 Lesson 6 Adding and Updating SQL DataCompleting the Trip Maintenance applicationIn Lesson 5, you created the tripeditaction.cfm page to contain
Completing the Trip Maintenance application 131After the following SQL statement executes:INSERT INTO ClientsVALUES ('Smith', 'Kaleigh&
132 Lesson 6 Adding and Updating SQL DataTip: To save time, you can copy this code from the tripsinsertquery.txt file (for Windows users) or from t
Completing the Trip Maintenance application 1334 In the tripedit.cfm page, fill in the fields with the values in the following figure, then click Save
134 Lesson 6 Adding and Updating SQL Data7 Click Search. The TripResults page appears:8 Click the link to the NH White Mountains to display the det
Completing the Trip Maintenance application 135Reviewing the codeThe following table describes the SQL INSERT and cfquery code used to add data:For mo
136 Lesson 6 Adding and Updating SQL DataThe cfinsert tag used in the previous code snippet uses the following attributes:Exercise: insert trip dat
Completing the Trip Maintenance application 137<cfupdate datasource="CompassTravel" tablename="Trips"><cflocation url=&qu
138 Lesson 6 Adding and Updating SQL DataFor more information about adding data to a database using the cfupdate tag, see Developing ColdFusion MX
Completing the Trip Maintenance application 139<cfset eventTypeIdentifier = #TripQuery.eventType#><cfset tripLocation = ''><c
The Internet and related technologies 5Intranet applicationsAn intranet is a private LAN (Local Area Network) or WAN (Wide Area Network) that lets you
140 Lesson 6 Adding and Updating SQL Data3 Insert the following code just before the last line:<!--- EDIT BUTTON ---><cfelseif IsDefined(&
Completing the Trip Maintenance application 141After the following SQL statement executes:UPDATE Clients SET LastName = ’Pitt’WHERE ID = 3the table co
142 Lesson 6 Adding and Updating SQL Data3 Add the following code:<!---Routine to increase trip price by 10% ---><cfquery name="TripQ
143INDEXAaction page, defined 26application. See tutorialCcfform, defined 99cfif, defined 59cfinput, defined 99cfinsert, defined 129cflocation, define
144 Indexsyntax 18URLEncodedFormat 81HHTML, defined 6IInternetapplications 4defined 4intranetapplication 5defined 5IsDefined function, defined 81JJava
6 Chapter 1 Introducing ColdFusion MXWeb browsersA web browser is a software program residing on a computer that you use to view pages on and navig
The Internet and related technologies 7URLsEvery piece of information on the World Wide Web has a unique address. This address is called a Uniform Res
8 Chapter 1 Introducing ColdFusion MXWeb application servers process code in a page that a browser and web server cannot interpret. The web server
What is ColdFusion MX? 9The ColdFusion application serverThe ColdFusion application server is a software program that resides on the same computer as
TrademarksAfterburner, AppletAce, Attain, Attain Enterprise Learning System, Attain Essentials, Attain Objects for Dreamweaver, Authorware, Authorware
10 Chapter 1 Introducing ColdFusion MXDevelopment toolsWhile you can code your ColdFusion application with NotePad or any HTML editor, Macromedia r
Using ColdFusion MX with Macromedia Flash MX 11Using ColdFusion MX with Macromedia Flash MXMacromedia Flash MX is designed to overcome the many limita
12 Chapter 1 Introducing ColdFusion MX
13CHAPTER 2CFML BasicsThis chapter introduces the basic elements of CFML, including how to create ColdFusion pages, and use variables, functions, cond
14 Chapter 2 CFML BasicsWorking with ColdFusion pagesAs discussed in Chapter 1, ColdFusion pages are plain text files that you use to create web ap
Working with ColdFusion pages 15To create a ColdFusion page:1 Open your editor and create a blank file.2 Enter the following code on the page:<html
16 Chapter 2 CFML BasicsThe following figure shows the cfpage.cfm in the browser:2 Do the following tasks:a View the source code that was returned
Understanding CFML elements 17Most often the end tag encloses the tag name in brackets and includes a slash (/), like this:</tagname>The informa
18 Chapter 2 CFML BasicsThe DollarFormat function returns a value as a string and formats that value with two decimal places, thousand separator, a
Understanding CFML elements 19If you did not include the pound signs around the DateFormat(Now(), "mm/ddyyy") function, the output for the p
iiiCONTENTSABOUT THIS BOOK . . . . . . . . . . . . . . . . . . . . . . . . . . . VIIDeveloper resources . . . . . . . . . . . . . . . . . . . . . . .
20 Chapter 2 CFML BasicsIn the next example, ColdFusion uses the values of the my_first_name and my_last_name variables to set the value for the my
Working with CFML expressions 21One of the tags that ColdFusion provides to display output is the cfoutput tag. The cfoutput tag instructs ColdFusion
22 Chapter 2 CFML BasicsAs mentioned, it is important that elements are identified properly in your expression so ColdFusion processes them as expe
Working with CFML expressions 23Specifying quotation marks around valuesWhen assigning literal values to variables, you must surround the literal valu
24 Chapter 2 CFML BasicsArithmetic operatorsThe following table lists the arithmetic operators that ColdFusion supports:String operatorThe followin
Understanding conditional processing 25Understanding conditional processing To this point, all the coding examples shown are considered linear coding
26 Chapter 2 CFML BasicsUsing cfelseif to evaluate multiple expressionsTo evaluate multiple expressions in a cfif statement, you can use cfelseif a
Processing form data 27When a user submits a form, the form values are stored in form variables and sent to the action page for processing. The follow
28 Chapter 2 CFML BasicsCommenting your codeAs in other programming languages, it is important to include comments in the code. You should comment
29CHAPTER 3Database FundamentalsThis chapter provides a quick overview of relational database concepts and terms. It describes what a database is and
iv Contents Processing form data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .26Form
30 Chapter 3 Database FundamentalsUnderstanding database basicsEven though you do not need a thorough understanding of database management systems
Understanding database basics 31Understanding relational tablesIn a database, you can organize data in multiple tables. For example, if you manage a d
32 Chapter 3 Database FundamentalsAbout SQLSQL Structured Query Language) is a language that lets you communicate with databases. For example, you
Using SQL with ColdFusion 33Using SQL with ColdFusionColdFusion communicates with your data source through a database interface called JDBC. JDBC is a
34 Chapter 3 Database Fundamentals
35CHAPTER 4Configuring Your DevelopmentEnvironmentThis chapter describes how to set up your development environment for the tutorial in Part II of thi
36 Chapter 4 Configuring Your Development EnvironmentVerifying the tutorial file structureBefore you being the tutorial, verify that the configurat
Configuring database connection and debugging options 37The photos directory contains the required photo files for the tutorial application. The solut
38 Chapter 4 Configuring Your Development Environment4 Specify the following:5 Click Show Advanced Settings and ensure that the settings for CLOB a
Configuring database connection and debugging options 393 Click Add to configure the data source name and driver. The PointBase data source dialog box
C o n t e n t s vLESSON 3 Creating a Main Application Page . . . . . . . . . . . . . . . . 81Enhancing the Trip Maintenance application. . . . .
40 Chapter 4 Configuring Your Development Environment7 Click Verify All Connections to ensure that ColdFusion can access this file. OK appears in t
Configuring database connection and debugging options 41The location of the debugging information or the type of debugging data shown varies, dependin
42 Chapter 4 Configuring Your Development EnvironmentFor the purpose of the tutorial in Part II of this book, enable the following debugging option
Macromedia development environment tools 43Macromedia development environment toolsMacromedia Dreamweaver MX is the preferred development environment
44 Chapter 4 Configuring Your Development EnvironmentThe Dreamweaver MX environmentAs a ColdFusion developer, you can build ColdFusion MX applicati
Macromedia development environment tools 45Configuring Dreamweaver MX for ColdFusion developmentBefore you use Dreamweaver MX to create the sample app
46 Chapter 4 Configuring Your Development Environment
PART IIBuilding a ColdFusionApplicationPart II provides a tutorial that steps you through building a sample ColdFusion application. It consists of six
49LESSON 1Preparing to Build the SampleApplicationIn this tutorial, you will build a simple ColdFusion web application for a fictitious travel company
vi Contents
50 Lesson 1 Preparing to Build the Sample ApplicationApplication development stepsMost software applications perform three major functions:• A user
Determining the application functional requirements 51Determining the application functional requirementsBefore you can build the sample application,
52 Lesson 1 Preparing to Build the Sample ApplicationDetermining the data requirementsPrior to creating the application pages to capture trip infor
Designing the database for your application 53Designing the database for your applicationAfter you identify the information to collect, you must consi
54 Lesson 1 Preparing to Build the Sample ApplicationEstablishing a relationship between the two tablesWhen the user selects an event type from the
Developing the sample application 55Developing the sample applicationGiven the application functional requirements and the database provided, you are
56 Lesson 1 Preparing to Build the Sample ApplicationEach lesson guides you through a scenario to enhance the Compass Travel Trip Maintenance appli
Developing the sample application 57RequirementsTo use this tutorial, you must have the following components installed:• ColdFusion Server For informa
58 Lesson 1 Preparing to Build the Sample Application
59LESSON 2Writing Your First ColdFusionApplicationIn this lesson, you begin the construction of a ColdFusion web application for the fictitious compan
viiABOUT THIS BOOKGetting Started Building ColdFusion MX Applications is intended for anyone who wants to learn how to use ColdFusion MX to create web
60 Lesson 2 Writing Your First ColdFusion ApplicationCreating your first ColdFusion applicationAs you recall from Lesson 3, two of the requirements
Creating your first ColdFusion application 61• Trip Search Results page The purpose of the Trip Search Results page is to display the results of a tri
62 Lesson 2 Writing Your First ColdFusion ApplicationUsing a web page to list tripsTo help Compass Travel agents take trip reservations by telephon
Using a web page to list trips 63Consider a table named Clients to hold information about people with the following rows:To select the columns named L
64 Lesson 2 Writing Your First ColdFusion ApplicationFor example, to select the columns named Last Name and First Name for Clients whose City is Bo
Using a web page to list trips 65the Trip List page presented earlier in this lesson. In this example, you use cfquery to return all the trip names fo
66 Lesson 2 Writing Your First ColdFusion ApplicationCreating a dynamic web pageIn the following exercises you will build a dynamic Trip Listing we
Using a web page to list trips 67Reviewing the codeThe following table describes the code used to build the query:Exercise: enhancing the queryIn this
68 Lesson 2 Writing Your First ColdFusion Application3 Create the Budget Trip List report by doing the following:a Modify the SQL SELECT statement,
Developing a search capability 69Developing a search capabilityThe dynamic listings developed in the previous exercise meet many of Compass Travel’s r
viii About This BookDeveloper resourcesMacromedia, Inc. is committed to setting the standard for customer support in developer education, document
70 Lesson 2 Writing Your First ColdFusion Application• price• tripIDIn later exercises, you will reference these columns when you build the SQL SEL
Developing a search capability 71Using SQL operators to create a search criteria pageA simple design for a search criteria page presents an operator l
72 Lesson 2 Writing Your First ColdFusion Application<td><select name="departureOperator"><option value="EQUALS"
Developing a search capability 73Building the Search Results page Based on the queryable columns identified earlier, the SQL query to display the sear
74 Lesson 2 Writing Your First ColdFusion ApplicationBuilding a SQL WHERE clause in code is largely an exercise in string concatenation. The &
Developing a search capability 75<!--- Create Where clause for query from data entered thru search form ---><cfset WhereClause = " 0=0 &
76 Lesson 2 Writing Your First ColdFusion ApplicationReviewing the codeThe following table describes the code used to build the tripLocation WHERE
Developing a search capability 77The Trip Results page displays several entries as follows:c Notice in the Trip Results page that only one trip has a
78 Lesson 2 Writing Your First ColdFusion Application2 To build the departureDate WHERE subclause, enter the code in the following table immediatel
Developing a search capability 794 Verify that the price and departureDate are now considered in the query, as in step 4 in the previous exercise:a Op
About Macromedia ColdFusion MX documentation ixAbout Macromedia ColdFusion MX documentationThe ColdFusion documentation is designed to provide support
80 Lesson 2 Writing Your First ColdFusion ApplicationSummaryThis lesson described how to access a relational database using ColdFusion. You used th
81LESSON 3Creating a Main Application PageIn this lesson you will enhance the Compass Travel Trip Maintenance application. The exercises in this lesso
82 Lesson 3 Creating a Main Application PageEnhancing the Trip Maintenance applicationIn this lesson you will enhance the Trip Maintenance applicat
Enhancing the Trip Maintenance application 83• Enhanced Trip Search Results page. The original purpose of the Trip Search Results page in Lesson 2 was
84 Lesson 3 Creating a Main Application PageThe primary users of these components will be the Compass Travel coordinators and agents, not the gener
Enhancing the Trip Maintenance application 85Exercise: building a Trip Detail pageFollow these steps to build a Trip Detail page.To build a Trip Detai
86 Lesson 3 Creating a Main Application Page<td>#returnDate#</td></tr><tr><td valign="top">Price:</td>
Enhancing the Trip Maintenance application 878 The Rio Cahabon Rafting trip has an tripID of 24. To view the trip detail for the trip in your browser
88 Lesson 3 Creating a Main Application PageReviewing the codeThe following table describes the ColdFusion code used to build the Trip Detail page:
Enhancing the Trip Maintenance application 89Protecting your applicationTo ensure that your application is protected from such an attack, you can expl
Commentaires sur ces manuels