 |
Breaking
eBusiness and Search News |
|
 |
Return Format For ColdFusion Components In ColdFusion 8
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.
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
View All Articles by Raymond Camden
Receive
Our Daily Email of Breaking eBusiness News
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.
WebProNews RSS Feed
More Expert Articles Articles
Contact WebProNews |
|
|
eBUSINESS
RESOURCES |
|
|
 |
|
| About
WebProNews |
WebProNews is the number
one source for eBusiness News. Over 5 million eBusiness professionals read
WebProNews and other iEntry business and tech publications.
WebProNews provides real-time coverage of internet
business.
Free Email Newsletters:
|
|
|
|