Programming instructions
Enhancing the Trip Maintenance application 121
Maintenance action page
The maintenance action page processes a user’s maintenance request from the Trip Detail
page. The request can be any of the following actions:
• Delete the currently displayed trip.
• Launch the search facility.
• Add a new trip (implemented in the previous two lessons).
• Update the currently displayed trip (implemented in the previous two lessons).
Application development steps
You will review or participate in the following application construction steps:
Using dynamic SQL to browse (navigate) the Trips table
The tripID uniquely identifies a trip in the Trips table. In Lesson 3, you displayed the
Trip Detail page for a trip by passing the ID as a parameter of the URL launching the
detail page. Therefore, you would navigate to the following URL to display the detail
information for a trip with the ID of 20:
http://localhost/cfdocs/getting_started/my_app/tripdetail.cfm?ID=20
The main objective of the Navigation Action page (navigationaction.cfm) is to navigate
to the Trip Detail page with a proper URL identifying the correct
tripID based on the
navigation button clicked. Unfortunately, because trips are added and later deleted, trips
might not be ordered sequentially by ID.
There can be missing IDs where trips were
deleted. Therefore, if the current trip ID is 1 and the user clicks the next navigation
button, it will not navigate to 2.
In order to ensure that the proper
tripID is retrieved, you must create a query to the
database to find out what the next (or previous, first, or last) ID is based on the current
tripID. The navigation action page uses dynamic SQL to build a query to find the
appropriate ID to use.
In Lesson 2, you used ColdFusion string manipulation to construct the proper SQL
SELECT WHERE clause. In this lesson, you will use a similar approach to build the
WHERE clause for navigation. Additionally, it is necessary to use the proper ORDER
BY clause to select the correct trip row.
Steps Description
1 Build the navigation action page to navigate and display the proper trip record.
2 Build the maintenance action page to process the user’s selection on the Trip
Detail page.