116
Chapter 9: Lesson 5: Implementing the Browsing and Maintenance Database Functions
3
To handle the Search and Delete buttons from the Trip Detail page, enter the following code:
<!---
SEARCH BUTTON--->
<cfif IsDefined("Form.btnSearch")>
<cflocation url="tripsearch.cfm">
<!---
DELETE BUTTON --->
<cfelseif IsDefined("Form.btnDelete")>
<cfquery name="DeleteRecord" dataSource="CompassTravel">
DELETE FROM trips WHERE tripID = #Form.RecordID#
</cfquery>
<cflocation url="tripdetail.cfm">
</cfif>
4
Save the page as maintenanceaction.cfm in the my_app directory.
5
View the tripdetail.cfm page in a browser.
The current trip is Nepal. Notice that the destination for Nepal Summit Challenge
trip is Imji
Himal, Nepal.
6
Click Search.
The Trip Search page appears.
7
In the Trip Search page, select Begins With in the selection box for Trip Location. Then enter
Imji in the trip location value field.
8
Click Search. Verify that only a single trip is found whose location
begins with
Imji.
9
To return to the Trip Detail page for this trip, click the hyperlink.
10
In the Trip Detail page, click Delete to remove this record from the Trip database file.
11
Verify that the trip record was removed from the Trips database by repeating the search in step
7.
Summary
In this lesson, you converted the Trip Detail page from the search result display into a trip
browser by using
cfquery
with SQL SELECT. The browser enables users to navigate sequentially
through the Trips table. You also limited the result set of the dynamic query using the
MaxRows
attribute of the
cfquery
tag.
By implementing 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.
Additionally, you used
cfquery
and SQL DELETE to delete the current trip.
In the next lesson
You have implemented two of the four maintenance buttons on the Trip Detail page. In the next
lesson, you will implement the Add and Edit buttons. The user input must be validated against
the Compass Travel business rules before the data is saved to the database. Therefore, in the next
lesson, you also will implement the business rule validation. In the final lesson, you will add the
database update logic.
Summary of Contents for COLDFUSION MX 61-GETTING STARTED BUILDING COLDFUSION...
Page 1: ...Getting Started Building ColdFusion MX Applications...
Page 6: ...6 Contents...
Page 10: ......
Page 30: ...30 Chapter 2 CFML Basics...
Page 36: ...36 Chapter 3 Database Fundamentals...
Page 48: ......
Page 76: ...76 Chapter 6 Lesson 2 Writing Your First ColdFusion Application...
Page 134: ...134 Index...