Enhancing the Trip Maintenance application
111
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: Creating a Main Application
Page
, 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: Writing Your First ColdFusion Application
, 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.
For example, if the current tripID equals 6, the following table identifies the proper SQL
statement based on the navigation button clicked by the user:
Step
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.
Navigation button
SQL statement to navigate to
correct trip ID
SQL statement description
First Row
SELECT tripID FROM trips
ORDER BY tripID
Returns the list of all
tripIDs
in ascending
(1,2,3...) order.
Previous Row
SELECT tripID FROM trips
WHERE tripID < 6
ORDER BY tripID DESC
Returns the list of all
tripIDs
less than 6 in
descending (5,4,3...) order.
Содержание 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...