
867
DEVELOPING
COLDFUSION 9 APPLICATIONS
Requesting and Presenting Information
Las
t
upda
te
d 8/5/2010
•
It calls a CFC, which uses only the first letter of the first name when forming the e-mail address, and forces the
domain name to be all lowercase.
The following example shows the bindapp.cfm page:
<html>
<head>
</head>
<body>
<cfform name="mycfform">
First Name: <cfinput type="text" name="firstname" value=""><br>
Last Name: <cfinput type="text" name="lastname" value=""><br>
Domain: <cfinput type="text" name="domain" value=""><br>
E-mail: <cfinput type="text" name="email"
bind="cfc:bindFcns.getEmailId({firstname@keyup},{lastname@keyup},
{domain@keyup})">
</cfform>
</body>
</html>
The following example shows the bindFcns.cfc CFC file:
<cfcomponent>
<cffunction name="getEmailId" access="remote">
<cfargument name="firstname">
<cfargument name="lastname">
<cfargument name="domain">
<cfreturn
"#left(arguments.firstname,1)#.#arguments.lastname#@#lcase(arguments.domain)#">
</cffunction>
</cfcomponent>
Many of the examples in the documentation for ColdFusion Ajax features use binding, including more complex forms
of binding.
Using the cfajaxproxy tag to bind to display controls
The
cfajaxproxy
tag with a
bind
attribute makes any of the following elements dependent on one or more bound
ColdFusion Ajax controls:
•
A single CFC function
•
A single JavaScript function
•
An HTTP request; for example, the URL of a CFML page
The function or request executes whenever a specific event (by default, the
onChange
event) of the bound control
occurs.
Note:
if you specify a bind attribute with a URL, the HTTP request includes a _
CF
_
NODEBUG
URL parameter. ColdFusion
checks this value, and when it is
true
, does not append to the response any debugging information that it normally would
send. This behavior ensures that JSON responses to Ajax requests do not include any non-JSON (that is, debugging
information) text.
The
cfajaxproxy
tag includes the following attributes that determine how the proxy handles the data returned by the
function or the page:
•
The
onError
function specifies code to handle an HTTP error return. You use this attribute with a URL or CFC bind.