Programming instructions
124 Lesson 5 Implementing the Browsing and Maintenance Database Functions
Exercise: implement trip record browsing (navigation)
Follow these steps to implement the trip record browsing functionality (navigation
buttons) on the Trip Detail page. In this exercise, you will use the supplied navigation
action page to implement and test the navigation buttons on the Trip Detail page.
To implement the trip record browsing functionality:
1 Copy the navigationaction.cfm file from the solutions subdirectory in the
getting_started directory to the my_app directory.
2 View the tripdetail.cfm page from the my_app directory in a browser and test the
navigation buttons as follows:
aClick Next Row.
The Trip Detail page shows information about the second trip.
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.
dClick 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 user’s 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")>
...
Button Action taken in maintenaceaction.cfm
Search Navigate to tripsearch.cfm built in Lesson 4.
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.