Programming instructions

C o n t e n t s v
LESSON 3 Creating a Main Application Page . . . . . . . . . . . . . . . . 81
Enhancing the Trip Maintenance application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .82
Showing additional trip details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .84
Avoiding the potential security risk when using dynamic SQL . . . . . . . . . . . . . . . . . . . . .88
Linking the Search Results page to the Trip Detail page. . . . . . . . . . . . . . . . . . . . . . . . . .89
Enhancing the look of the search results and detail pages . . . . . . . . . . . . . . . . . . . . . . . . .90
Creating the main application page from the Trip Detail page . . . . . . . . . . . . . . . . . . . . .93
Adding navigation buttons to browse database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .94
Adding database maintenance buttons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .96
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .98
In the next lesson . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .98
LESSON 4 Validating Data to Enforce Business Rules . . . . . . . . 99
Enhancing the Trip Maintenance application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .100
Using an HTML form to collect data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .101
Developing code to validate data and enforce business rules. . . . . . . . . . . . . . . . . . . . . . . .103
Validating data using a server-side action page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .104
Validating data on the client using ColdFusion form tags. . . . . . . . . . . . . . . . . . . . . . . .107
Using cfselect tag to present valid event types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .110
Using other client-side script to reduce edits on the server . . . . . . . . . . . . . . . . . . . . . . .112
Validating the existence of the trip photo file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .115
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .117
In the next lesson . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .117
LESSON 5 Implementing the Browsing and Maintenance
Database Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .119
Enhancing the Trip Maintenance application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .120
Application development steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .121
Using dynamic SQL to browse (navigate) the Trips table . . . . . . . . . . . . . . . . . . . . . . . .121
Building the maintenance action page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .124
Linking the Trip Detail page to the Trip Search page. . . . . . . . . . . . . . . . . . . . . . . . . . .125
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .128
In the next lesson . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .128
LESSON 6 Adding and Updating SQL Data . . . . . . . . . . . . . . . . . 129
Completing the Trip Maintenance application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .130
Writing code to save new trips to the database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .130
Updating a SQL row using cfupdate. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .136
Linking the Trip Edit page to the main page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .138
SQL Update. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .140
Updating multiple records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .141
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .142
INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143