Completing the Trip Maintenance application
125
Exercise: update trip data using cfupdate
In this exercise, you will add the code to update the trip data into the database. You will add the
cfupdate
tag to the tripeditaction.cfm page.
To update the database using cfupdate:
1
In an editor, open tripeditaction3.cfm from the solutions directory.
2
Review the code to update the database (the last 12 lines of code).
3
Verify that the correct photolocation path is specified. This path is specified in the
<cfset
PhotoLocation = "C:...">
tag.
For example, depending on your web server configuration, the photolocation path might be:
■
For MS Windows systems:
<cfset PhotoLocation
"C:\cfusionmx\wwwroot\CFDOCS\getting_started\Photos\">
or
<cfset PhotoLocation =
"C:\Inetpub\wwwroot\CFDOCS\getting_started\Photos\">
■
For Linux or Solaris systems:
<cfset PhotoLocation = "/opt/cfusionmx/wwwroot/cfdocs/
getting_started/photos/">
or
<cfset PhotoLocation = "/<webserverdocroot>/cfdocs/
getting_started/photos/">
4
Save the file as tripeditaction.cfm in the my_app directory.
For more information about adding data to a database using the
cfupdate
tag, see
Developing
ColdFusion MX Applications
.
Now that you have built the data entry form adding new and updating existing trips, you will add
the logic to link it to the main trip page to test the update logic.
Linking the Trip Edit page to the main page
As discussed in
Lesson 4: Validating Data to Enforce Business Rules
, 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 the next exercise you will insert the code to call tripedit.cfm
from maintenance.cfm as follows:
<!---
EDIT BUTTON --->
<cfelseif IsDefined("Form.btnEdit")>
<cflocation url="tripedit.cfm?ID=#Form.RecordID#">
<!---
ADD BUTTON --->
<cfelseif IsDefined("Form.btnAdd")>
<cflocation url="tripedit.cfm">
</cfif>
Содержание COLDFUSION MX 61-GETTING STARTED BUILDING COLDFUSION...
Страница 1: ...Getting Started Building ColdFusion MX Applications...
Страница 6: ...6 Contents...
Страница 10: ......
Страница 30: ...30 Chapter 2 CFML Basics...
Страница 36: ...36 Chapter 3 Database Fundamentals...
Страница 48: ......
Страница 76: ...76 Chapter 6 Lesson 2 Writing Your First ColdFusion Application...
Страница 134: ...134 Index...