User Guide

Table Of Contents
Using ColdFusion components 223
To invoke component methods using a form:
1.
Create a corpFind.cfm file with the following contents:
<h2>Find People</h2>
<form action="components/corpQuery.cfc?method="getEmp" method="post">
<p>Enter employee's last Name:</p>
<input type="Text" name="lastName">
<input type="Hidden" name="method" value="getEmp">
<input type="Submit" title="Submit Query"><br>
</form>
In the example, the form tags action attribute points to the corpQuery component and
invokes the
getEmp method.
2.
Create a corpQuery.cfc file, specifying access="remote" for each cffunction tag, as the
following example shows:
<cfcomponent>
<cffunction name="getEmp" access="remote">
<cfargument name="lastName" required="true">
<cfset var empQuery="">
<cfquery name="empQuery" datasource="cfdocexamples">
SELECT LASTNAME, FIRSTNAME, EMAIL
FROM tblEmployees
WHERE LASTNAME LIKE '#arguments.lastName#'
</cfquery>
<cfoutput>Results filtered by #arguments.lastName#:</cfoutput><br>
<cfdump var=#empQuery#>
</cffunction>
</cfcomponent>
3.
Open a web browser and enter the following URL:
http://localhost/corpFind.cfm
ColdFusion displays the search form. After you enter values and click the Submit Query
button, the browser displays the results.
Accessing CFCs from outside ColdFusion and basic HTML
Flash applications that use Flash Remoting MX can easily take advantage of ColdFusion
components for business logic. Similarly, you can export CFCs so that any application can access
CFC methods as web services.
Using Flash Remoting MX
For ColdFusion component methods to communicate with Flash Remoting MX applications,
you must set the
access attribute of the cffunction tag to remote.
For more information on creating CFCs for Flash Remoting MX, see Chapter 33, “Using the
Flash Remoting Service,” on page 807.