|
Recent
Articles |
Return Format For ColdFusion Components... One of the lesser publicized updates in ColdFusion 8 is the introduction of the returnFormat attribute for the cffunction tag. What does this do? ColdFusion Components, when executed remotely, will return...
Getting The Value Of AJAX-ified Controls I ran into a problem last night trying to use JavaScript to read the value of a rich text field. I had assumed I could use the normal syntax I'd use for a form field: document.forms[0].body.value or document...
Enhancements In ArcGIS At 9.3 & Simple Mashup... ArcGIS Server 9.3, the next version of the popular app will be an incremental release… support for integrated security, better cashing, more options in building apps and simple mashup applications, deploy REST...
Adobe's ColdFusion 8 Beta The wait is over and the latest version of ColdFusion has just been released in beta. Code named 'Scorpio' (the eighth sign of the Zodiac) during the development stages, the new release is officially named...
Section 508 & WAI Triple A Accessibility I've been fiddling with accessibility standards and validation today. It's something I've been doing for several years now on many different types of web applications. So today it was time for my blog...
|
|
 |
|
07.11.07
Return Format For ColdFusion Components In ColdFusion 8
By Raymond Camden
One of the lesser publicized updates in ColdFusion 8 is the introduction of the returnFormat attribute for the cffunction tag.
What does this do? ColdFusion Components, when executed remotely, will return data wrapped in WDDX format. This is a problem if you want to use the result in AJAX or some other non-WDDX form. ColdFusion 7 fixed this partially by making any function that had a returnType of XML return it's data unformatted.
ColdFusion 8 takes this further and allows you to explicitly state how the result data should be returned. You can specify:
• WDDX
• JSON
• plain
As you can probably guess, the "plain" format will do nothing to your result at all. This will only work if your data is a simple value. There is no such thing as a "plain" result for arrays.
| Learn How We Increased Conversion By 816% and Become A Certified Online Testing Professional™ Click Here |
|
What's interesting is that you can set the returnformat on the fly when you make a request. Imagine that you've requested:
http://localhost/foo.cfc?method=transform
The default behavior will be the same as what you saw in ColdFusion 7. If the returntype isn't XML, you get WDDX. But now you can change this with the request:
http://localhost/foo.cfc?method=transform&returnFormat=JSON
This will return the same data, but encoded in JSON instead of WDDX. This URL,
http://localhost/foo.cfc?method=transform&returnFormat=plain
Will return the data as is - not encoded at all. An interesting use of this would be a service that lets you embed an ad or other "widget". I could build a "Ray's Daily Tip" service that could be embeddable with a CFHTTP call.
Comments
About the Author: Raymond Camden, ray@camdenfamily.com
http://ray.camdenfamily.com
Raymond Camden is Vice President of Technology for roundpeg, Inc. A long
time ColdFusion user, Raymond has worked on numerous ColdFusion books
and is the creator of many of the most popular ColdFusion community web
sites. He is an Adobe Community Expert, user group manager, and the
proud father of three little bundles of joy.
|