System information

66 Chapter 6: Lesson 3: Retrieving Data
Let Dreamweaver do it
Dreamweaver lets you invoke a method in a CFC without having to write the code.
To invoke the method using Dreamweaver:
1.
Click the Components tab in the Application panel.
2.
Click the + button next to cfdocs.getting_started.my_app.components.
3.
Click the + button next to gettrips.
4.
Select query basicList() and drag it to the top of the triplisting.cfm file.
5.
Change the value of the returnvariable to be the name of the query, TripList, as follows:
returnvariable="TripList"
6.
Return to Step 3 in the “To invoke the method:” procedure.
Exercise 5: Creating additional queries
In this exercise, you will improve the Trip List page to make it easier for the Compass Travel
agents to locate trips. You must make the following improvements:
Sort the trip names in alphabetical order.
Display the departure date, return date, and price for each trip.
Develop a Budget Trip List report that identifies trips that are priced $1500 or less.
You could modify the existing query; however, you may need to use that query in the future.
Instead, you can create an additional method in the gettrips.cfc component with a query that
meets the preceding requirements. You can then call the new methods with the enhanced query
from the triplisting.cfm page. Display the triplisting.cfm page in the browser after each step to
ensure that the corresponding requirement was met.
To modify the application, you must:
Create the query that meets the requirements.
Invoke the method that contains the query.
Display the results.
Creating the query
To continue writing structured, reusable code, you create the query in a method in the existing
CFC.
To create a method with enhanced query results:
1.
Open the gettrips.cfc file.
2.
Enter the following code just before the closing cfcomponent tag, or do the steps in the “Let
Dreamweaver do it section.
<cffunction name="getBudgetTrips" displayName="Budget trip list"
hint="List trips under $1500 alphabetically"
access="public"
returnType="query"