Coldfusion 8 has serialized objects, native JSON support and more

Posted on May 1, 2007

Ben Forta presented Coldfusion 8 (Scorpio) to the DFW CFUG tonight. We had a huge turn out, including some old friends and former coworkers. As the Scorpio tour progresses, Ben will be unveiling new features at each stop so we saw stuff that hadn’t yet been presented anywhere else.

Of the many things we saw tonight, some I’d seen at AdobeMAX 2006, some I’d seen in the beta, but others were news to me.

Server Monitoring

This is the number one new feature in Coldfusion 8 that could be THE reason to upgrade. Not only does CF8 ship with a custom Flex UI to monitor slow threads, slow queries, memory usage and more, they have opened up an API so you can roll your own monitoring tools should you like.

Serialized Objects

When you run multiple instances of Coldfusion, session variables can be be recreated as one instance dies and the session is moved to another instance. Currently however, components stored in session can’t be replicated.

This means that if you store a user bean (CFC) in session, you have to find some way of recreating the object when an instance dies. In CF8, the user object can cross over just as easily as any other Coldfusion variable.

Native JSON support

JSON (JavaScript Object Notation) is a standard way of exchanging data. It’s an easy way to pass data to and from AJAX, so now Coldfusion can return a query record set, array or other data types in native JSON format.

Standard Operators

The clouds have parted and the light shines down on us. They’ve finally added standard operators to Coldfusion. No longer do we have to spend hours trying to run down a bug in nested object calls due to being in the zone while coding.

Up until now, to compare A against B, we had to do the following in <cfscript>:

<cfscript>
if (A gt B) {
  foo();
}
if (B lt A) {
  bar();
}
</cfscript>

we can now use standard operators

<cfscript>
if (A > B) {
  foo();
}
if (B < A) {
  bar();
}
</cfscript>

We also get to use the following:

&&, ||, <=, >=, ++, == // and more

Updated definitions and syntax

Coldfusion 8 will allow you to define and populate structs and arrays in a new manner. I forget the struct syntax, but here’s how you can now define an array.

<cfset foo = arrayNew(1) />
<cfset arrayAppend( foo, "John" ) />
<cfset arrayAppend( foo, "Wayne" ) />
<cfset arrayAppend( foo, "Henry" ) />

<!--- CF 8 syntax --->
<cfset foo = ["John", "Wayne", "Henry"] />

Tag attributes can be defined using an argumentcollection variable instead of strictly writing out each one.

<cfset attr = structNew() />
<cfset attr.name = "someQuery" />
<cfset attr.DSN = "someDSN" />
<cfset attr.user = "someDBUser" />
<cfset attr.password = "someDBPassword" />

<cfquery argumentcollection="#attr#">

A larger example can be found on Ben Forta’s blog.

About the Author
Adrian J. Moreno

Adrian is an enterprise solution architect and full stack developer. Which stack depends on which system is on fire at the time. More information