Exercise 7: Validating The Existence Of The Trip Photo File - MACROMEDIA COLFUSION MX 7-GETTING STARTED BUILDING COLDFUSION MX Getting Started

Building coldfusion mx applications
Table of Contents

Advertisement

Replace the following eventtypes code lines:
4.
<cfselect size="1" name="eventType" required="Yes"
message="Type of event must be selected.">
<option value="1" selected>Surfing</option>
<option value="2">Mountain Climbing</option>
<option value="3">Mountain Biking</option>
</cfselect>
with these lines:
<cfselect size="1" name="eventType" required="Yes"
message="Type of event must be selected.">
<cfoutput query="GetEvents">
<option value="#GetEvents.eventTypeID#">
#GetEvents.eventType#
</option>
</cfoutput>
</cfselect>
Save the file.
5.
To test the modified code:
View the tripedit.cfm page in a browser.
1.
Select the event types drop-down list. Notice that all seven event types appear in the list.
2.

Exercise 7: Validating the existence of the trip photo file

At this point, you have a more efficient application. The client is handling much of the validation
of the Compass Travel new trip business rules. Except for the trip photo file, the server receives
only valid data.
The trip photo file business rule does not fit nicely into this design, however. This business rule
has two parts:
A photo filename must accompany all new trips.
The photo image file must reside in the images directory of the Compass Travel website.
You used the
required
Now you must ensure that the file exists in the right directory so that the application can display
it to the user.
Because browser clients are prohibited from doing standard file input and output (I/O) on the
web server, the Trip Maintenance application uses server-side validation to ensure the existence of
the photo file. You add the business rule for the photo file to the tripeditaction.cfm page.
To verify that a file exists, ColdFusion provides a
following syntax:
FileExists(absolute_path)
This function returns Yes if the file specified in the argument does exist; otherwise, it returns No.
Note: The trip photo images are stored in the following path relative to your web root directory:
\cfdocs\getting_ started\photos. Therefore, if your web root is C:\inetpub\wwwroot, the photos are
stored in the C:\inetpub\wwwroot\cfdocs\getting_ started\photos directory.
120
Chapter 10: Lesson 7: Validating Data to Enforce Business Rules
attribute for the photo
tag to ensure that a filename is entered.
cfinput
function. This function has the
FileExists

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the COLFUSION MX 7-GETTING STARTED BUILDING COLDFUSION MX and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Colfusion mx 7 - installing and using coldfusion mx

Table of Contents