System information

Exercise 1: Creating a Trip Detail page 87
To build the CFC query:
1.
Create a blank ColdFusion page.
2.
Save the file as tripdetail.cfm in the my_app directory.
3.
Perform the following steps, or do the steps in the “Let Dreamweaver do it section.
a
Enter the following code:
<cfinvoke
component="cfdocs.getting_started.my_app.components.displaytripdetail"
method="getTripDetails"
returnvariable="tripDetails">
</cfinvoke>
b
Save the file.
c
Create a file named displaytripdetail.cfc in the my_app/components directory.
d
Enter the following code:
<cfcomponent>
<cffunction name="getTripDetails" access="public" returntype="query">
<cfset var tripDetails = "" >
<cfquery name="tripDetails" datasource="CompassTravel" maxrows=1>
SELECT * FROM trips
<cfif IsDefined("URL.ID")>
WHERE tripID = #URL.ID#
</cfif>
</cfquery>
<cfreturn tripDetails>
</cffunction>
</cfcomponent>
e
Save the file.
Let Dreamweaver do it
You can use the Dreamweaver Extensions to build the CFC query.
To create the CFC query in Dreamweaver:
1.
Open a new file in the my_app directory in Dreamweaver.
2.
Save the file as tripdetail.cfm.
3.
Click the Bindings tab.
4.
Click the + button.
5.
Select Recordset (Query).
6.
In the Name text box, enter tripDetails.
7.
In the Data sources list, select CompassTravel.
8.
Click the CFC Query button.
9.
In the Name text box, enter tripDetails.
10.
Click the Create New Component button.
11.
In the Name text box, enter displaytripdetail.