User Guide

114 Chapter 9: Lesson 5: Implementing the Browsing and Maintenance Database Functions
b Click Previous Row.
The Trip Detail page shows information about the first trip.
c Click Last Row.
The Trip Detail page shows information about the last trip.
d Click First Row.
The Trip Detail page shows information about the first trip.
Building the maintenance action page
The maintenance action page (maintenanceaction.cfm) handles the users maintenance requests.
The delete request is handled directly within the maintenance action page. The search request is
accomplished by linking the Trip Search page. The maintenance action page navigates to another
page for data capture for add and edit requests.
You will build the tripedit.cfm page to capture the information for add and edit requests in the
next lesson. The following table identifies the button clicked on the Trip Detail page with the
action taken in the
maintenance action page:
Maintenance action page code
ColdFusion creates a variable only for the button that the user clicked. Therefore, the
IsDefined
function is used to test which action to take. The following code is an excerpt from the
maintenanceaction.cfm page that tests which action to take:
<cfif IsDefined("Form.btnSearch")>
...
<cfelseif IsDefined("Form.btnDelete")>
...
<cfelseif IsDefined("Form.btnEdit")>
...
<cfelseif IsDefined("Form.btnAdd")>
...
</cfif>
The first two buttons are the easiest to handle because they do not require building any new
pages. Therefore, you will implement the functionality for the
Search and Delete buttons first.
Linking the Trip Detail page to the Trip Search page
The ColdFusion
cflocation tag navigates from the current page to a target HTML or CFML
page. The URL attribute contains the name of the target page and any arguments. The code to
navigate to the search page (tripsearch.cfm) follows:
<cflocation url="tripsearch.cfm">
Button Action taken in maintenaceaction.cfm
Search Navigate to tripsearch.cfm built in Lesson 4: Validating Data to Enforce Business
Rules.
Delete Execute SQL DELETE statement for current
tripID.
Edit Navigate to tripedit.cfm with ID parameter in URL set to current tripID.
Add Navigate to tripedit.cfm with ID parameter in URL set to blank.