Adobe COLDFUSION 9 Manual page 200

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Building Blocks of ColdFusion Applications
If the CFC method that you invoke from the form displays output directly, the user's browser shows the output. (You
can use the cffunction tag
output
tag, ColdFusion converts the text to HTML edit format, places it in a WDDX packet, and includes the packet in the
HTML that it returns to the client.
Create a corpFind.cfm file with the following contents:
1
<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
method.
Create a corpQuery.cfc file, specifying
2
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>
Open a web browser and enter the following URL:
3
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 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.
For ColdFusion component methods to communicate with Flash Remoting applications, set the
the
tag to
cffunction
remote
For more information on creating CFCs for Flash Remoting, see
Any application, whether it is a ColdFusion application, a Java application, JSP page, or a .Net application, can access
well-formed ColdFusion components as web services by referencing the WSDL file that ColdFusion automatically
generates.
To see a component's WSDL definition, specify the component web address in a URL, followed by ?wsdl; for example:
http://localhost:8500/MyComponents/arithCFC.cfc?wsdl
For more information on using CFCs as web services, see
attribute to disable displaying output.) If the CFC returns a result using the cfreturn
tag's
attribute points to the
action
access="remote"
.
Last updated 8/5/2010
component and invokes the
corpQuery
for each
tag, as the following example
cffunction
"Using the Flash Remoting
"Using Web
Services" on page 1093
195
getEmp
attribute of
access
Service" on page 606

Advertisement

Table of Contents
loading

Table of Contents