Adobe COLDFUSION 9 Manual page 199

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

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Building Blocks of ColdFusion Applications
<cfobject name="userDataCFC" component="userData">
<cfif DateDiff("d", userDataCFC.lastUpdated, Now()) GT 30>
<!--- Code to deal with older data goes here. --->
</cfif>
For more information, see
"The This
Invoking CFC methods with forms and URLs
You can invoke CFC methods directly by specifying the CFC in a URL, or by using HTML and CFML form tags.
Because all HTTP requests are transient, these methods only let you transiently invoke methods. They do not let you
create persistent CFC instances.
Invoking component methods by using a URL
To invoke a component method by using a URL, append the method name to the URL in standard URL query-string,
name-value syntax. You can invoke only one component method per URL request, for example:
http://localhost:8500/tellTime.cfc?method=getLocalTime
Note: To use URL invocation, set the
To pass parameters to component methods using a URL, append the parameters to the URL in standard URL query-
string, name-value pair syntax; for example:
http://localhost:8500/corpQuery.cfc?method=getEmp&lastName=camden
To pass multiple parameters within a URL, use the ampersand character (&) to delimit the name-value pairs; for
example:
http://localhost:8500/corpQuerySecure.cfc?method=getAuth&store=women&dept=shoes
Note: To ensure data security, Adobe strongly recommends that you not pass sensitive information over the web using
URL strings. Potentially sensitive information includes all personal user information, including passwords, addresses,
telephone numbers, and so on.
If a CFC method that you access using the URL displays output directly, the user's browser shows the output. You can
suppress output by specifying
ColdFusion converts the text to HTML edit format (with special characters replaced by their HTML escape sequences),
places the result in a WDDX packet, and includes the packet in the HTML that it returns to the client.
Invoking component methods by using a form
To invoke a method by using a ColdFusion or HTML form, do the following:
• Specify the CFC filename or path in the
• Specify the CFC method in a hidden form field, as follows:
<form action="myComponent.cfc" method="POST">.
<input type="Hidden" name="method" value="myMethod">
• Alternatively, if you use the POST method to submit the form, you can follow the filename with
methodname, where methodname is the name of the CFC method, as shown in the following line. You
?method=
cannot use this technique with the GET method.
<form action="myComponent.cfc?method=myMethod" method="POST">.
• Create an input tag for each component method parameter. The
parameter name and the field value is the parameter value.
• Specify the
access="remote"
scope" on page 198.
attribute of the
access
"
" in the
output=
No
cffunction
or cfform tag
form
attribute in the cffunction tag that defines the CFC method being invoked
Last updated 8/5/2010
tag to
.
cffunction
remote
tag. If the CFC returns a result using the cfreturn tag,
attribute.
action
attribute of the tag must be the method
name
194

Advertisement

Table of Contents
loading

Table of Contents