Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 876

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

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Requesting and Presenting Information
• You use the
setReturnFormat
WDDX format, or as plain text. Use the
query as an object with an array of column names and an array of row arrays, or as an object that corresponds to
the WDDX query format. These functions only effect the format of data returned by ColdFusion. Data sent from
the proxy to the server is always in JSON format.
Submitting data to a CFC
When you use an Ajax CFC proxy, you send to the CFC function any client-side data that can be serialized to JSON
format, not just form data. However, the proxy cannot serialize DOM tree elements because they are wrappers on
native code. Therefore, you cannot use DOM tree elements directly as parameters to a CFC function that you call by
using an Ajax proxy. To ensure correct serialization to JSON for sending to the CFC, use basic JavaScript types only:
array, object, and simple types. Instead of using a DOM element directly, you pass only the specific element attributes
that you require to the CFC function, either individually or in an array or object.
When you use the
attribute, you submit form data to the CFC without refreshing the client page by calling the
cfc
proxy
function before you call a CFC proxy function in your JavaScript. The proxy function then passes all
setForm
field values of the specified form to the CFC function. In the CFC function Arguments scope, the argument names are
the form control
attributes (or, by default, the
ID
Note: You cannot use the
setForm
To pass the form parameters to your proxy function, invoke the proxy function immediately after you call the
function. Subsequent proxy function invocations do not get the form parameters.
If you also pass arguments explicitly to the CFC,
arguments must precede any
JavaScript function:
function submitForm() {
var proxy = new remoteHandler();
proxy.setCallbackHandler(callbackHandler);
proxy.setErrorHandler(errorHandler);
proxy.setForm('myform');
proxy.setData('loggedIn');
}
In this example, the remoteHandler.cfc setData function starts as follows:
<cffunction name="setData" access="remote" output="false">
<cfargument name="loggedIn">
<cfargument name="userName">
...
In this example,
is the name of a form field. If the
userName
tag for the
explicitly passed variable, the CFC function would not get the value of
loggedIn
function can omit
cfargument
Example: Using an asynchronous CFC proxy
The following example uses a remote CFC method to populate a drop-down list of employees. When you select a name
from the list, it uses a call to the CFC method to get information about the employee, and displays the results.
The main application page has the following lines:
function to specify whether to return the result in JSON format (the default), in
setQueryFormat
attributes) and the argument values are the control values.
name
function to submit the contents of file fields.
cfargument
tags for the form fields. For example, if you have the following submitForm
cfargument
tags for the form fields.
Last updated 1/20/2012
function to specify whether to return a JSON format
tags in the CFC function that specify the explicitly passed
tag for
cfargument
userName
setForm
preceded the
cfargument
. Your CFC
loggedIn
871

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents