68
Chapter 6: Lesson 3: Retrieving Data
Invoking the new method
To use the new query, you invoke the method that contains the query.
To invoke the new method with the enhanced query:
1.
Open the triplisting.cfm file.
2.
Modify the following code, or do the steps listed in the
“Let Dreamweaver do it”
section.
<cfinvoke
component="cfdocs.getting_started.my_app.components.gettrips"
method="
getBudgetTrips
"
returnvariable="
budgetTrips
">
</cfinvoke>
3.
Save the file.
Let Dreamweaver do it
You can use the Dreamweaver Extensions to create the CFC query and invoke the method that
contains the query from the triplisting.cfm page.
To invoke the enhanced CFC query in Dreamweaver:
1.
Delete the
cfinvoke
code block.
2.
Click the Components tab.
3.
Click the + button next to cfdocs.getting_started.my_app.components, and click the + button
next to gettrips.
4.
Select query getBudgetTrips and drag it to the top of the file.
5.
Change the value of the
returnvariable
to be the name of the query, budgetTrips, as follows:
returnvariable="budgetTrips"
6.
Save the file.
Displaying the results
To display the results of the new query, you refer to the new query in the
cfoutput
block and
include all the columns that you want to display.
To display the results of the enhanced query
1.
Change the output block in the triplisting.cfm file to output all three selected fields from the
enhanced query, as follows:
<cfoutput query="budgetTrips">
#tripName#
departs: #departureDate#
returns: #returnDate#
price: #price#<BR>
</cfoutput>
2.
Change the heading tag in the triplisting.cfm file from
<h1>Trip List</h1>
to
<h1>Budget
Trip List</h1>
.
Содержание COLFUSION MX 7-GETTING STARTED BUILDING COLDFUSION...
Страница 1: ...COLDFUSION MX7 Getting Started Building ColdFusion MX Applications...
Страница 6: ...6 Contents...
Страница 10: ......
Страница 14: ...14 Chapter 1 Introducing ColdFusion MX...
Страница 38: ...38 Chapter 3 Database Fundamentals...
Страница 40: ......
Страница 58: ...58 Chapter 5 Lesson 2 Configuring Your Development Environment...
Страница 70: ...70 Chapter 6 Lesson 3 Retrieving Data...
Страница 84: ...84 Chapter 7 Lesson 4 Building Dynamic Queries...
Страница 96: ...96 Chapter 8 Lesson 5 Creating a Trip Detail Page...
Страница 102: ...102 Chapter 9 Lesson 6 Creating a Main Application Page...