![]() ![]() ![]() |
||
|
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:
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:
To continue writing structured, reusable code, you create the query in a method in the existing CFC.
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" output="false"> <cfquery name="budgetTrips" datasource="CompassTravel"> SELECT tripName, departureDate, returnDate, price FROM trips WHERE price <= 1500 ORDER BY tripName </cfquery> <cfreturn budgetTrips> </cffunction>
You can use the Dreamweaver Extensions to create a CFC query and invoke the method that contains the query from the triplisting.cfm page.
cfcomponent
tag.
To use the new query, you invoke the method that contains the query.
<cfinvoke component="cfdocs.getting_started.my_app.components.gettrips" method="getBudgetTrips" returnvariable="budgetTrips"> </cfinvoke>
You can use the Dreamweaver Extensions to create the CFC query and invoke the method that contains the query from the triplisting.cfm page.
cfinvoke
code block.
returnvariable
to be the name of the query, budgetTrips, as follows:
returnvariable="budgetTrips"
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.
<cfoutput query="budgetTrips">
#tripName#
departs: #departureDate#
returns: #returnDate#
price: #price#<BR>
</cfoutput>
<h1>Trip List</h1>
to <h1>Budget Trip List</h1>
.
The dates and prices in the preceding listing are not formatted. In Lesson 6: Creating a Main Application Page, you will enhance the look of this page.
|
||
![]() ![]() ![]() |