Developing Code To Validate Data And Enforce Business Rules - MACROMEDIA COLDFUSION MX 61-GETTING STARTED BUILDING COLDFUSION MX Getting Started

Building coldfusion mx applications
Table of Contents

Advertisement

Exercise: view the source and test the Trip Edit page
To view the source and test the Trip Edit data collection form:
Open an editor, then locate and open the file tripedit1.cfm in the solutions directory
1
\cfdocs\getting_started\solutions under your web root directory.
Review the HTML source code used to create the Trip Edit page. If you are not fluent in
2
HTML, the following table explains the use of some of the HTML tags in the Trip Edit page.
For more information on HTML, consult any HTML primer.
Tag
Description
Form
You create a data entry form by using the
attributes; for example:
<form action="tripeditaction.cfm" Method= "Post">
Here, the
server will navigate to in response to the form's submission. The
specifies how data is returned to the web server. Submit all ColdFusion forms using
the
Table
You can format a data entry form and display its controls neatly, by using the table
tag,
Form
The form requires controls to collect and submit user input. There are a variety of
Controls
types of form controls you can use. For this lesson, you will use the following
controls:
Save the file as tripedit.cfm to the my_app directory.
3
View the tripedit.cfm in a browser and test the form by entering a trip name in the Trip Name
4
field then clicking Save. An error occurs.
View the form source (tripedit.cfm) in an editor to try to determine the cause of the error.
5
Notice that the
indicates the page to receive the form values posted by the tripedit.cfm page. Since the page,
tripeditaction.cfm, does not exist yet, ColdFusion MX sends an error.
At this point, this form does not store any information in the database and does not enforce any
business rules of Compass Travel. In the next exercise, you will develop the action page to enforce
the business rules.

Developing code to validate data and enforce business rules

As described in
Lesson 1: Preparing to Build the Sample
right data type for each column on the tables in the database. A fundamental concern, therefore,
is ensuring that the captured data is suitable for the column definitions in the Trips table. This
type of validation on a single field is often referred to as a single-field edit.
Compass Travel has other operating policies that involve evaluating the values from more than
one field. These validations, referred to as cross-field edits, are usually more difficult to program.
To assure that new trips are uniformly captured, Compass Travel has published cross-field
validations and single-field edits in its Compass Travel business rules.
attribute specifies the name of the ColdFusion file that the web
action
attribute.
Post method
, table row tag,
table
Accepts text answers such as Trip Name and Trip Price.
<input>
<input type=checkbox>
Provides user with a list of possible answers such as the
<select>,<option>
event type (Mountain Biking, Surfing, and so on).
Gathers user input on multiple lines such as for the Trip Description.
<textarea>
<input type=submit>
tag on line 6 of the source code has an
<form>
Developing code to validate data and enforce business rules
tag. The
form
, and the table data tag,
tr
Asks yes or no questions, such as Deposit Required?
Posts the information collected to the server.
Application, it is important to define the
tag takes two tag
form
attribute
method
.
td
attribute. This attribute
action
95

Advertisement

Table of Contents
loading
Need help?

Need help?

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

Subscribe to Our Youtube Channel

This manual is also suitable for:

Coldfusion mx

Table of Contents