Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 875

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Requesting and Presenting Information
Using ColdFusion Ajax CFC proxies
Use the
tag to create a client-side JavaScript proxy for a CFC and its functions. The proxy object has the
cfajaxproxy
following characteristics:
• It provides a JavaScript function that corresponds to each CFC remote function. Calling these functions in your
client-side JavaScript code remotely calls the CFC functions on the server.
• It provides JavaScript support functions for controlling the communication, which specifies asynchronous result
and error handler callbacks, and sends form data to the server. For detailed information on these functions, see the
cfajaxproxy tag in the CFML Reference.
• It manages the interactions between the client and the CFC, including serializing and deserializing JavaScript arrays
and structures to and from JSON format for transmission over the web.
• It ensures automatic serialization (into JSON format) and deserialization of CFC return values.
By using a ColdFusion Ajax proxy, any JavaScript code can call the proxied CFC functions. Thus, any Ajax application,
not just one that uses ColdFusion Ajax UI elements, can use dynamic data provided by CFCs. Also, the proxy provides
access to all of the functions in a CFC, not just the single function that you specify in a bind expression.
Creating a JavaScript CFC proxy
The
tag with a
cfajaxproxy
Because a ColdFusion page that uses the
with the
tag (or tags), and the remainder of the page consists of the HTML and JavaScript required to
cfajaxproxy
control the display and perform the page logic on the client.
Note: Because JavaScript is case-sensitive, make sure that you match the case of the keys in any ColdFusion structure or
scope that you send to the client. By default, ColdFusion sets variable names and structure element names to all-
uppercase. (You create structure element names with lowercase characters by specifying the names in associative array
notation, for example,
myStruct["myElement"]="value"
ColdFusion
SerializeJSON
and
.
data
For more information about creating and using CFC proxies, see the cfajaxproxy tag in the CFML Reference.
Configuring the CFC proxy
The proxy provides several JavaScript functions that you use to control the behavior of the proxy:
• You use the
setAsyncMode
functions are asynchronous, the most common synchronization method for Ajax applications.
• You use the
setCallbackHandler
of successful and unsuccessful asynchronous calls.
Note: For error handling to work properly, select the Enable HTTP Status Codes option on the Server Settings >
Settings page of the ColdFusion Administrator.
• You use the
setHTTPMethod
request.
• You use the
function to prepare the proxy to send full form data to the remote function. This function
setForm
causes the proxy to pass each form field as a separate parameter to the CFC function.
attribute generates a JavaScript proxy that represents a CFC on the web client.
cfc
tag is used as an Ajax client web page, the page typically starts
cfajaxproxy
function generates to represent a query are
and
functions to control the call mode. By default, all calls to remote CFC
setSyncMode
and
setErrorHandler
function to control whether the call uses a GET HTTP request (the default) or a POST
Last updated 1/20/2012
.) The keys for the two arrays in the JSON object that the
and
COLUMNS
DATA
functions to specify the functions that handle the results
, for example, not
columns
870

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents