User Guide

Table Of Contents
222 Chapter 10: Building and Using ColdFusion Components
Invoking component methods using a URL
To invoke a component method using a URL, you must 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, you must set the
access attribute of the cffunction tag to remote.
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, Macromedia 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
output="No" in the cffunction tag. If the
CFC returns a result using the
cfreturn tag, ColdFusion converts the text to HTML edit format
(with special characters replaced by their HTML escape sequences), puts the result in a WDDX
packet, and includes the packet in the HTML that it returns to the client.
Invoking component methods using a form
To invoke a method using a ColdFusion or HTML form, the following must be true:
The form or cfform tag action attribute must specify the CFC filename or path followed by
?method=methodname, where methodname is the name of the method; for example, <form
action="myComponent.cfc?method=myMethod" method="POST">.
The form must have an input tag for each component method parameter. The name attribute
of the tag must be the method parameter name and the field value is the parameter value.
The cffunction tag that defines the CFC method being invoked must specify the
access="remote" attribute.
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 attribute to disable displaying
output.) If the CFC returns a result using the
cfreturn tag, ColdFusion converts the text to
HTML edit format, puts it in a WDDX packet, and includes the packet in the HTML that it
returns to the client.