Exercise 2: Determining Actions Based On Which Button A User Clicks; Exercise 3: Enabling Searching From The Trip Detail Page - MACROMEDIA COLFUSION MX 7-GETTING STARTED BUILDING COLDFUSION MX Getting Started

Building coldfusion mx applications
Table of Contents

Advertisement

Exercise 2: Determining actions based on which button a
user clicks
In
"Lesson 6: Creating a Main Application Page" on page
Detail page to let users search and modify the trips database; however, because you had not yet
written the code to implement these capabilities, ColdFusion displayed an error when you clicked
the buttons. Clicking these button sends the user to the maintenanceaction.cfm page. In this
exercise, you will create the Maintenance Action page (maintenanceaction.cfm).
ColdFusion creates a variable only for the button that the user clicked. You use the
function to test for the existence of the variable, which determines which action the application
takes.
To create the Maintenance Action page:
Create a blank file.
1.
Enter the following code in the blank file:
2.
<cfif IsDefined("Form.btnSearch")>
<!--- Code to execute if the user clicked Search. --->
<cfelseif IsDefined("Form.btnDelete")>
<!--- Code to execute if the user clicked Delete. --->
<cfelseif IsDefined("Form.btnEdit")>
<!--- Code to execute if the user clicked Edit. --->
<cfelseif IsDefined("Form.btnAdd")>
<!--- Code to execute if the user clicked Add. --->
</cfif>
Save the file as maintenanceaction.cfm in the my_app directory.
3.

Exercise 3: Enabling searching from the Trip Detail page

You already created a search capability when you created the tripsearchform.cfm page in
4: Building Dynamic Queries" on page
navigate to the tripsearchform.cfm page. You use the
To enable searching from the Trip Detail page:
Open the maintenanceaction.cfm file in the my_app directory in your editor.
1.
Add the highlighted code in the file.
2.
<cfif IsDefined("Form.btnSearch")>
<!--- Code to execute if the user clicked Search. --->
<cflocation url="tripsearchform.cfm">
<cfelseif IsDefined("Form.btnDelete")>
<!--- Code to execute if the user clicked Delete. --->
<cfelseif IsDefined("Form.btnEdit")>
<!--- Code to execute if the user clicked Edit. --->
<cfelseif IsDefined("Form.btnAdd")>
<!--- Code to execute if the user clicked Add. --->
</cfif>
Save the file.
3.
97, you added buttons to the Trip
71. When the user clicks the Search button, you want to
cflocation
Exercise 3: Enabling searching from the Trip Detail page
IsDefined
tag to do so.
"Lesson
127

Advertisement

Table of Contents
loading

This manual is also suitable for:

Colfusion mx 7 - installing and using coldfusion mx

Table of Contents