background image

Exercise 1: Enabling users to browse trip details

125

Limiting the number of result rows

Each of the SQL statements in the preceding table returns a result set of trips rows. The result set 
can range

 

from zero to any number of rows. The Navigation Action page must limit the result set 

count to 1, because only the initial row in the result set appears on the Trip Detail page. 

ColdFusion provides the 

maxRows

 attribute for the 

cfquery

 tag for this purpose. This attribute 

limits the number of result rows returned from the database. To show only a single row at a time 
in the Trip Detail page, set 

maxRows

 to 1. 

To build the Navigation Action page:

1.

Create a blank file.

2.

Enter the following code in the blank file:

<!---

NAVIGATION BUTTONS --->

<cfquery name="TripQuery" datasource="CompassTravel" maxrows="1">

SELECT tripID FROM trips
<cfif IsDefined("Form.btnPrev.X")>

WHERE tripID < #Form.RecordID#
ORDER BY tripID DESC

<cfelseif IsDefined("Form.btnNext.X")>

WHERE tripID > #Form.RecordID#
ORDER BY tripID

<cfelseif IsDefined("Form.btnFirst.X")>

ORDER BY tripID

<cfelseif IsDefined("Form.btnLast.X")>

WHERE tripID > #Form.RecordID#
ORDER BY tripID DESC

</cfif>

</cfquery>
<cfif TripQuery.RecordCount is 1>

<cflocation url="tripdetail.cfm?ID=#TripQuery.tripID#">

<cfelse>

<cflocation url="tripdetail.cfm?ID=#Form.RecordID#">

</cfif>

3.

Save the file as navigationaction.cfm in the my_app directory.

Note: 

In previous lessons, you adhered to good coding practices by putting queries in ColdFusion 

components. To optimize performance, and because the Navigation Action page contains only a 
query, the page is a ColdFusion page rather than a CFC. For more information about code reuse, see 
Chapter 8, “Creating ColdFusion Elements” in 

ColdFusion MX Developer’s Guide

.

Содержание COLFUSION MX 7-GETTING STARTED BUILDING COLDFUSION...

Страница 1: ...COLDFUSION MX7 Getting Started Building ColdFusion MX Applications...

Страница 2: ...these links only as a convenience and the inclusion of the link does not imply that Macromedia endorses or accepts any responsibility for the content on those third party sites Copyright 1999 2005 Ma...

Страница 3: ...ocessing 27 Processing form data 28 Commenting your code 30 CHAPTER 3 Database Fundamentals 31 About database basics 31 About SQL 34 Using SQL with ColdFusion 36 PART II Building a ColdFusion Applicat...

Страница 4: ...eria on the Trip Search form 82 Exercise 6 Testing the revised Trip Search Results page 83 Summary 83 CHAPTER 8 Lesson 5 Creating a Trip Detail Page 85 Exercise 1 Creating a Trip Detail page 86 Exerci...

Страница 5: ...ing the current trip record shown on the Trip Detail page 129 Exercise 2 Adding trips with SQL INSERT statements 131 Exercise 3 Adding data using the cfinsert tag 135 Exercise 4 Updating a SQL row usi...

Страница 6: ...6 Contents...

Страница 7: ...dia com go livedocs_cfmx7docs_installing Configuring and Administering ColdFusion MX Part I describes how to manage the ColdFusion environment including connecting to your data sources and configuring...

Страница 8: ...in LiveDocs which lets you add comments to pages and view the latest comments added by Macromedia by going to www macromedia com go livedocs_cfmx7docs CFML Reference Provides descriptions syntax usag...

Страница 9: ...7 It defines ColdFusion MX 7 and provides an overview of the ColdFusion Markup Language CFML It also provides generic database concepts The following chapters are included in Part I Chapter 1 Introdu...

Страница 10: ......

Страница 11: ...ts ColdFusion application server ColdFusion Markup Language CFML ColdFusion MX Administrator The following sections describe these core components in more detail In addition the Getting Started Experi...

Страница 12: ...er with an Internet connection You can manage the following configuration options with the ColdFusion MX Administrator ColdFusion data sources Debugging output Server settings Application security For...

Страница 13: ...with existing Open Database Connectivity ODBC data sources by using ODBC Socket a driver that interacts with an existing ODBC driver Interacting with mobile devices ColdFusion MX 7 lets you create app...

Страница 14: ...14 Chapter 1 Introducing ColdFusion MX...

Страница 15: ...27 Processing form data 28 Commenting your code 30 Working with ColdFusion pages ColdFusion pages are plain text files that you use to create web applications You can create your ColdFusion applicatio...

Страница 16: ...erstand this process is to create a ColdFusion page In the following procedure you will create a simple ColdFusion page by using HTML tags one ColdFusion tag and two ColdFusion functions The following...

Страница 17: ...usion page 1 Create a directory called test under the web_root or web_application_root directory 2 In the test directory save the file as cfpage cfm Browsing your code To ensure that the code you wrot...

Страница 18: ...m operations such as accessing a database Functions can return data and do other operations like retrieving the system date Almost everything that you want to accomplish with ColdFusion involves using...

Страница 19: ...L Reference Tag attributes Tag attributes instruct ColdFusion about the details of an operation For example to update a database table ColdFusion requires specific information about the database such...

Страница 20: ...eFormat Now mm dd yyyy function ColdFusion would not evaluate the function and the previous example would display your source code as follows For more information about how to use number signs with fu...

Страница 21: ...store data in memory on the server Variables always have a name and a value You can assign a value to a variable or you can instruct ColdFusion to assign variable values based on data that it retrieve...

Страница 22: ...important because ColdFusion supports many types of variables Use the following syntax to reference a local variable variables variablename Because ColdFusion lets you use the same name with variables...

Страница 23: ...xample the following code creates a variable and instructs the ColdFusion server to return the value of the variable cfset my_first_name Kaleigh cfset my_last_name Smith cfset my_full_name variables m...

Страница 24: ...ccurring when you combine CFML on a page with case sensitive languages such as JavaScript Specifying number signs to denote functions or variables In ColdFusion you specify number signs to denote func...

Страница 25: ...ring My name is variables my_first_name and my age is variables my_age My name is is literal text and you therefore surround it with quotation marks The variable references variables my_first_name and...

Страница 26: ...hin a second value DOES NOT CONTAIN Tests whether a value is not contained within a second value Operators Description The basic arithmetic operators addition subtraction multiplication and division I...

Страница 27: ...se When using these tags you can facilitate decision making in your code The most fundamental tags used to control code execution are the cfif cfelse and cfelseif tags Because you will see and use the...

Страница 28: ...red by the user If the user enters MA in the state form field the state tax results returned is 8 5 If the user enters VA in the state form field the state tax results returned is 8 2 If the user ente...

Страница 29: ...m tag uses the following syntax form action actionpagename cfm method Post HTML and CFML form tags form The first attribute action in the form tag lets you specify where to send the data The page that...

Страница 30: ...code on the page it is easier to make modifications Commented code tends to be better organized Comment tag The ColdFusion comment tag is similar to the HTML comment tag except that it has three dashe...

Страница 31: ...nguage SQL that you use to interact with databases Contents About database basics 31 About SQL 34 Using SQL with ColdFusion 36 About database basics Even though you do not need a thorough understandin...

Страница 32: ...Columns represent individual fields in a table Rows represent records of data in a table You can think of database tables as grids as in the following example Each field in the table contains one pie...

Страница 33: ...ormation is the same for each employee in a given department however repeating the department information for each employee is redundant Storing redundant data takes up more disk space If the departme...

Страница 34: ...e SQL SELECT statement retrieves columns of data from a database The tabular result is stored in a result table called the record set You use the following SELECT statement to retrieve information fro...

Страница 35: ...ith one or more conditions these are called subclauses You join subclauses using the operators AND and OR The AND operator displays a row if all conditions that are listed are True The OR operator dis...

Страница 36: ...a SQL database using the SELECT statement which are not described in this manual For more information consult a SQL reference Using SQL with ColdFusion ColdFusion communicates with your data source t...

Страница 37: ...ag is the name of the query The second attribute of the cfquery tag defines the name of the data source The SELECT statement defines the fields columns to be retrieved from a table named Employee CFML...

Страница 38: ...38 Chapter 3 Database Fundamentals...

Страница 39: ...ation 41 Lesson 2 Configuring Your Development Environment 49 Lesson 3 Retrieving Data 59 Lesson 4 Building Dynamic Queries 71 Lesson 5 Creating a Trip Detail Page 85 Lesson 6 Creating a Main Applicat...

Страница 40: ......

Страница 41: ...ore you will not need to design or build the Compass Travel database It is important however for you to be familiar with the layout of the database Additionally you must understand the functional requ...

Страница 42: ...es of a trip are important to Compass Travel For this you must determine the data requirements for the application Understanding the data requirements is essential to building the proper database to h...

Страница 43: ...el website can market its trips online to the general public Customers who are booking a trip need to know the trip name when the trip begins and ends the price and a description Additionally the trip...

Страница 44: ...umn so that your data collection forms can validate against incorrect values entered by the user Looking closer you might wonder why the eventType column is a number and not a text data type column Re...

Страница 45: ...ing in the eventtypes table new mountain climbing trips would be classified differently than ones saved before the change For this reason and to save space in the database the key to the eventtypes ro...

Страница 46: ...ge is where users will come to view information about trips and to navigate to other ColdFusion pages to add edit or search for new trips The following lessons explain how to do these tasks Configure...

Страница 47: ...docs getting_started solutions Appended to each filename is the lesson and exercise number For example the version of the file tripdetail cfm that you would have after performing the steps in Lesson 5...

Страница 48: ...n provided For information about how to configure the Compass Travel data source see Lesson 2 Configuring Your Development Environment on page 49 For additional information about configuring a data so...

Страница 49: ...structure Before you begin the tutorial verify that the configuration of the computer where ColdFusion MX 7 is installed matches the file structure described in the following sections The files requi...

Страница 50: ...images The image subdirectory contains the required image files for the tutorial application The photos directory contains the required photo files for the tutorial application The solutions director...

Страница 51: ...MX to build the sample ColdFusion application in this tutorial see the following sections for information about configuring Dreamweaver for ColdFusion development Configuring Dreamweaver MX for ColdF...

Страница 52: ...data source without leaving the Dreamweaver environment you need the following information The type of connection to use The name to call the data source The location of the database file s To configu...

Страница 53: ...ss procedure is for Windows users The PointBase procedure is for UNIX and Macintosh OS X users To define the connection to the sample Microsoft Access database 1 In the ColdFusion MX Administrator sel...

Страница 54: ...e that the name of the data source file does not contain any spaces If the name contains a space the data source connection fails Driver drop down selection box Select Other Field Action JDBC URL Ente...

Страница 55: ...g the ColdFusion MX 7 Administrator to set debugging options Viewing debugging information within Dreamweaver Instead of enabling debugging for an application you can view debugging information for an...

Страница 56: ...To enable debugging options 1 In the ColdFusion MX Administrator select Debugging Logging Debugging Settings A list of debugging options appears on the Debugging Settings page 2 Select the Enable Debu...

Страница 57: ...hen using a remote client 1 In the ColdFusion MX Administrator select Debugging Logging Debugging IP Addresses The Debugging IP Address page appears 2 In the IP Address text box enter the IP address o...

Страница 58: ...58 Chapter 5 Lesson 2 Configuring Your Development Environment...

Страница 59: ...sson introduce you to the process of retrieving data from the Compass Travel relational database This lesson contains the following exercises Exercise 1 About the trip list 60 Exercise 2 Retrieving th...

Страница 60: ...the page always shows an identical trip list it is considered a static web page You should only use static web pages when you are creating a page that is not likely to change often Using the static w...

Страница 61: ...are working in Dreamweaver ensure that the site that you created in Lesson 1 is the current site For more information see Configuring Dreamweaver MX for ColdFusion development on page 51 2 Open a new...

Страница 62: ...ery xxx output code block cfoutput Displaying the column contents from the SQL statement In CFML you surround variables with number signs to display their contents using the cfoutput tag You also use...

Страница 63: ...r application For more information see Chapter 10 Building and Using ColdFusion Components in ColdFusion MX Developer s Guide To move the query to a CFC 1 Create the CFC file 2 Copy the query to the C...

Страница 64: ...n cfcomponent 4 Save the file as gettrips cfc in the components directory Let Dreamweaver do it Dreamweaver lets you create a ColdFusion component without having to enter the code To create a CFC in D...

Страница 65: ...the results of the query to the triplisting cfm page cfreturn TripList 4 Save the gettrips cfc file Calling the query method To perform the query that is now in a method in a ColdFusion component you...

Страница 66: ...op a Budget Trip List report that identifies trips that are priced 1500 or less You could modify the existing query however you may need to use that query in the future Instead you can create an addit...

Страница 67: ...cfc file and position the pointer before the closing cfcomponent tag 2 Click the Bindings tab 3 Click the button 4 Select Recordset Query 5 In the Name text box enter budgetTrips 6 Click the New Funct...

Страница 68: ...block 2 Click the Components tab 3 Click the button next to cfdocs getting_started my_app components and click the button next to gettrips 4 Select query getBudgetTrips and drag it to the top of the...

Страница 69: ...the look of this page Summary This lesson described how to access a relational database using ColdFusion You used the SQL SELECT statement and the cfquery and cfoutput tags to display trip lists You...

Страница 70: ...70 Chapter 6 Lesson 3 Retrieving Data...

Страница 71: ...ercise 1 Creating the trip search form As you recall from Lesson 1 Preparing to Build the Sample Application on page 41 two of the requirements for the Trip Maintenance application are the ability to...

Страница 72: ...ify the trips with a price greater than 3 000 Show the trips departing after 11 11 2005 that are priced less than 2 000 There are a number of considerations to take into account when you design a sear...

Страница 73: ...suppose the user wants a list of all the trips where the trip location begins with a B SQL is well suited for this type of query Typical SQL string operators are equals starts with contains and ends...

Страница 74: ...H begins with select td td input type text name tripLocationValue td tr Field departureDate tr td Departure Date td td select name departureOperator option value EQUALS is option value BEFORE before o...

Страница 75: ...he form fields are posted to the Trip Search Results page The posted field values compose the WHERE clause in the SQL SELECT statement The following example lists the WHERE clauses that you can genera...

Страница 76: ...you use the following pseudocode cfif color EQ red statements for color red cfelse statements for other than red cfif Building a SQL WHERE clause in code is largely an exercise in string concatenation...

Страница 77: ...ractice of separating business logic and presentation you put the code to build the query using dynamic SQL in a function in the CFC that you have been working with To add the new query to the CFC 1 O...

Страница 78: ...do it You can use the Dreamweaver Extensions to create the CFC query To construct the query with Dreamweaver 1 Click the Bindings tab 2 Click the button 3 Select Record set Query 4 In the Name text bo...

Страница 79: ...Trip Search Results page 1 Create a blank document and save it as tripsearchresult cfm in the my_app directory Note If you are using Dreamweaver select Dynamic page in the Category list and ColdFusio...

Страница 80: ...ick the button next to gettrips 4 Select query getTripsFromForm and drag it to the top of the triplisting cfm file 5 Change the value of returnvariable to be the name of the query TripResult as follow...

Страница 81: ...cation drop down list select the Begins With option and enter the value C in the text box b Click Search The Trip Results page displays several entries as follows c Notice in the Trip Results page tha...

Страница 82: ...pointer before the cfquery code block 3 To build the departureDate WHERE subclause enter or copy and paste the code in the following table immediately before the cfquery code block For this database...

Страница 83: ...1900 as the date specify 1900 1 1 on UNIX 3 Select Smaller Than and enter 0 for the price 4 Click the Search button Because the departure date is considered in the query there are no rows returned Not...

Страница 84: ...84 Chapter 7 Lesson 4 Building Dynamic Queries...

Страница 85: ...unctions that you use in this lesson to enhance the sample ColdFusion application Element Type Description DollarFormat Function Returns a number as a String formatted with two decimal places a thousa...

Страница 86: ...dress of the page with an ID For example to view trip information for Rio Cahabon Rafting with tripID 24 you open a browser and enter the following URL http localhost cfdocs getting_started my_app tri...

Страница 87: ...s public returntype query cfset var tripDetails cfquery name tripDetails datasource CompassTravel maxrows 1 SELECT FROM trips cfif IsDefined URL ID WHERE tripID URL ID cfif cfquery cfreturn tripDetail...

Страница 88: ...by adding the highlighted text cfquery name tripDetails datasource CompassTravel maxrows 1 SELECT FROM trips cfif IsDefined URL ID WHERE tripID URL ID cfif cfquery 21 Save the file To display the resu...

Страница 89: ...rip Leader td td tripLeader td tr tr td valign top Number People td td numberPeople td tr tr td valign top Deposit Required td td depositRequired td tr tr td valign top Photo File td td photo td tr ta...

Страница 90: ...etail page 1 Open a browser 2 Enter one of the following URLs which use the tripID of 24 which specifies the Rio Cahabon Rafting trip http localhost cfdocs getting_started my_app tripdetail cfm ID 24...

Страница 91: ...QL statement is built dynamically In the Trip Maintenance application when the client program or user passes an ID in the URL that calls the Trip Detail page the page displays the relevant trip inform...

Страница 92: ...m attack To eliminate this risk you should use ColdFusion functions such as Val to perform type checking on all URL parameters For queries you can also use the cfqueryparam tag which is explained in C...

Страница 93: ...Enhancing the look of the Trip Search Results and Trip Detail pages The Trip Maintenance application now provides a useful drill down mechanism for locating trips Although this application is function...

Страница 94: ...returnDate and price indicated in the table 4 Save the file To view the application s new appearance 1 View the tripsearchform cfm page in the my_app directory in your browser 2 In the Trip Location...

Страница 95: ...ip Detail page to show more information about a particular trip You also formatted the Trip Search Results and Trip Detail pages using the CFML DateFormat and DollarFormat functions You linked the Tri...

Страница 96: ...96 Chapter 8 Lesson 5 Creating a Trip Detail Page...

Страница 97: ...t addressed The ability to browse through the Trips table The ability to add delete and edit trip information You will modify the Trip Detail page to accomplish this additional functionality The Trip...

Страница 98: ...85 is very useful when the user knows some search criteria to enter Flipping back and forth between the results page and the detail page to navigate through a record set can be tedious Moreover on occ...

Страница 99: ...ame btnLast src images last gif form Note The current trip record ID tripID is in a hidden field in the form code This field provides the action page with current record ID that it must have in order...

Страница 100: ...ceaction cfm page To add maintenance buttons 1 Open the tripdetail cfm file from the my_app subdirectory 2 Enter the following code immediately after the cfoutput query TripQuery tag form action maint...

Страница 101: ...use the Maintenance Action page does not exist The Maintenance Action page is required to process the maintenance button requests You will develop this page in Lesson 7 Validating Data to Enforce Busi...

Страница 102: ...102 Chapter 9 Lesson 6 Creating a Main Application Page...

Страница 103: ...of the trip photo file 120 ColdFusion tags and functions introduced in this lesson The following table describes the ColdFusion tags and functions that you use in this lesson to enhance the ColdFusion...

Страница 104: ...6 Creating a Main Application Page on page 97 The following figure shows the Trip Edit page The page appears when the user clicks the Add or Edit button on the main Trip Maintenance application page t...

Страница 105: ...TR TD valign top Departure Date TD TD INPUT name departureDate size 10 TD TR Field returnDate TR TD valign top Return Date TD TD INPUT name returnDate size 10 TD TR Field numberPeople TR TD valign to...

Страница 106: ...a data entry form by using the form tag The form tag takes two tag attributes for example form action tripeditaction cfm Method Post Here the action attribute specifies the name of the ColdFusion fil...

Страница 107: ...cfoutput body html 3 Save the page as tripeditaction cfm in the my_app directory To test the trip edit page 1 Open the tripedit cfm page in the my_app directory in a browser 2 In the Trip Name field...

Страница 108: ...use special tags to simplify the process of enforcing business rules Using ColdFusion it is possible to enforce business rules in several places For example you can enforce some validation edits on th...

Страница 109: ...le is to create a local variable with a cfset tag within the action page that tests whether any of the business rules failed The cfset tag lets you manipulate the value of a variable For example the f...

Страница 110: ...t evaluate to either True or False To use the cfif tag to test whether a trip name was entered business rule 1 on the Trip Edit form you add the following cfif statement cfif Form tripName EQ cfoutput...

Страница 111: ...ot IsDefined returns True if the specified variable is not found and the cfset statement sets the form variable to No A value of No indicates that a deposit is not required a value of Yes indicates th...

Страница 112: ...ng is selected by default there is always a value for event type 4 Trip locations are required Trip location is required cfif Form tripLocation EQ cfset IsOk No cfoutput Trip location cannot be blank...

Страница 113: ...cfoutput cfelse Price must be 20 greater than Base Cost cfif Form basecost 1 2 GT Form price cfset IsOk No cfoutput Price must be marked up at least 20 above cost cfoutput cfif cfif 8 Any trip priced...

Страница 114: ...data on the client using ColdFusion form tags In this exercise you will compare server side and client side validation You then modify the testedit cfm page to use client side scripting Comparing serv...

Страница 115: ...cannot be blank validate integer required Yes size 3 maxlength 3 Attribute Description validate The data type that the field tag validates against Values include integer date time telephone zipcode m...

Страница 116: ...llowing appropriate values The following table contains the revised code blocks Attribute value Description required Use this attribute for fields that must be filled out or selected validate Use this...

Страница 117: ...cfinput name departureDate size 10 required Yes validate date message Departure date must be a valid date cfinput name returnDate size 10 required Yes validate date message Return date must be a vali...

Страница 118: ...cfm page appears as follows cfset isOk Yes cfif not isdefined Form depositRequired cfset form depositRequired No cfif cfif Form price GT 750 AND Form depositRequired EQ No cfset IsOk No cfoutput Depos...

Страница 119: ...To retrieve the data from this table you must include the following cfquery cfquery name GetEvents datasource CompassTravel SELECT eventType eventTypeID FROM eventtypes cfquery To exploit the query in...

Страница 120: ...ule does not fit nicely into this design however This business rule has two parts A photo filename must accompany all new trips The photo image file must reside in the images directory of the Compass...

Страница 121: ...otoLocation C tag For example depending on your web server configuration the PhotoLocation path might be For MS Windows systems cfset PhotoLocation C CFusionMX7 wwwroot cfdocs getting_started photos o...

Страница 122: ...on you will write code to add trips to the database Additionally you will add logic to update existing trip data in the Trips table Code Explanation cfset PhotoLocation C CFusionMX7 wwwroot cfdocs get...

Страница 123: ...users to browse trip details In Lesson 6 Creating a Main Application Page on page 97 you added buttons to the Trip Detail page to browse records in the database In this exercise you build the action...

Страница 124: ...n 4 Building Dynamic Queries on page 71 you used ColdFusion string manipulation to construct the proper SQL SELECT WHERE clause In this lesson you use a similar approach to build the WHERE clause for...

Страница 125: ...ame TripQuery datasource CompassTravel maxrows 1 SELECT tripID FROM trips cfif IsDefined Form btnPrev X WHERE tripID Form RecordID ORDER BY tripID DESC cfelseif IsDefined Form btnNext X WHERE tripID F...

Страница 126: ...tripID FROM trips cfif IsDefined Form btnPrev X WHERE tripID Form RecordID ORDER BY tripID DESC cfelseif IsDefined Form btnNext X WHERE tripID Form RecordID ORDER BY tripID cfelseif IsDefined Form bt...

Страница 127: ...icked Search cfelseif IsDefined Form btnDelete Code to execute if the user clicked Delete cfelseif IsDefined Form btnEdit Code to execute if the user clicked Edit cfelseif IsDefined Form btnAdd Code t...

Страница 128: ...nting the Maintenance Action page you enabled users to take action on the current trip You used the ColdFusion cflocation tag to link the search page to the Trip Detail page In the next lesson You hav...

Страница 129: ...the Trip Edit page to the main page 138 Exercise 6 Inserting values in the edit form 139 ColdFusion tags introduced in this lesson The following table identifies the ColdFusion tags that you use in t...

Страница 130: ...nput tag from the Trip Detail page the following SQL statement deletes a row from the Trips table DELETE FROM trips WHERE tripID Form RecordID To enable users to delete trips 1 Open the maintenanceact...

Страница 131: ...because you deleted the trip Exercise 2 Adding trips with SQL INSERT statements In Lesson 8 Implementing Browsing and Searching on page 123 you built a Trip Edit page to collect the data Now you can m...

Страница 132: ...For this approach you use the following syntax INSERT INTO table_name column1 column2 VALUES value1 value2 For example to add Kaleigh Smith of Windham with an unknown address you use the named column...

Страница 133: ...Form tripLocation Form departureDate Form returnDate Form price Form tripLeader Form photo Form baseCost Form numberPeople Form depositRequired cfquery UNIX users using PointBase Insert the new trip...

Страница 134: ...the Begins With option and enter the value Nor in the text box 5 Click Search The TripResults page appears 6 Click NH White Mountains to display the details of the trip you just added Verify that all...

Страница 135: ...tes Code Explanation cfquery name AddTrip datasource CompassTravel Using the datasource attribute the cfquery tag connects to the CompassTravel data source and returns a result set identified by the n...

Страница 136: ...tRequired cfquery 3 Add the following cfinsert tag to insert data into the trips table in the same location as the code that you just deleted cfinsert datasource CompassTravel tablename trips 4 Save t...

Страница 137: ...the cfupdate tag has datasource and tablename attributes to specify where the data is to be inserted The tag also has a formfields attribute to identify which fields are to insert The formfields attr...

Страница 138: ...on page 103 the action page for the maintenance buttons on the main page is maintenanceaction cfm You previously added code for the Search and Delete buttons In this exercise you add code for the Add...

Страница 139: ...it cfm file in your editor 2 Enter or copy and paste the following code after the cfquery block that appears at the top of the file cfif IsDefined URL ID cfquery name TripQuery datasource CompassTrave...

Страница 140: ...ip Name to be blank if the ID is undefined otherwise set the value equal to the Trip Name that appeared on the Trip Detail page TD cftextarea name tripDescription required Yes message Trip description...

Страница 141: ...ed and must be numeric TD Set the value of the Price to be blank if the ID is undefined otherwise set the value equal to the Price that appeared on the Trip Detail page TD cfinput name baseCost size 1...

Страница 142: ...cfif IsDefined URL ID WHERE tripID ID cfif cfquery Set the local variables cfset tripName TripQuery tripName cfset eventType TripQuery eventType cfset tripDescription TripQuery tripDescription cfset...

Страница 143: ...sing the Login Wizard can perform simple authentication authentication against a Microsoft Windows NT domain or authentication against a Lightweight Directory Access Protocol LDAP server In Dreamweave...

Страница 144: ...the remote server You can move the application files to the remote server either by using the Login Wizard which uses Dreamweaver or by using Dreamweaver directly Creating an application that include...

Страница 145: ...from Dreamweaver To start the Login Wizard 1 Start Dreamweaver 2 Ensure that the active site is the one for which you want to restrict access Note The currently active site must be a local site The R...

Страница 146: ...nation for each application The Login Wizard creates the files necessary to restrict access to your application The Wizard then displays a list of the files 7 To deploy the modified application to you...

Страница 147: ...t only employees of Compass Travel can access the application you have built you use the Login Wizard to provide user authentication You specify only one username and password that all employees of Co...

Страница 148: ...CompassStaff as the user name 3 Enter Columbus92 as the password Summary In this lesson you learned how to use the Login Wizard to provide user authentication for a site and added user authentication...

Страница 149: ...ag 76 cfif tag 82 109 cfinput tag 103 cfinsert tag 129 cflocation tag 123 CFML basics 15 30 building applications 13 commenting code 30 elements 18 23 expressions 23 27 functions 19 operators 26 SQL 3...

Страница 150: ...displaying dates 66 query results 68 88 search results 79 trip information 60 trips by price 66 variables 62 DollarFormat function defined 85 Dreamweaver creating CFC queries 67 78 87 creating CFCs 6...

Страница 151: ...ber signs using 62 O operators about 25 27 for querying 73 P photo file testing existence of 120 PointBase database about 82 133 configuration 54 primary key defined 45 Q queries copying to CFCs 65 di...

Страница 152: ...trip search results page 79 tutorial adding and updating SQL data 129 application business rules 108 application requirements 42 creating main application page 85 95 97 101 data requirements 43 datab...

Отзывы: