Saturday, October 5, 2024

What’s Really Hot in CF MX

So you’re a ColdFusion guru and you thought you’d seen it all. You’ve mastered the ColdFusion 5 tags and functions completely, and you know what you can, and more importantly, what you cannot do with ColdFusion. You also were a little anxious when Macromedia took over, and some of you sigh at the loss of Spectra and try to keep the community going. So what’s next? What’s in the new ColdFusion MX for us gurus?

I was very fond of Allaire; I had the privilege of knowing a bunch of their really cool employees, and I thought Macromedia could never keep up with the spirit and vision of the Allaire people. They proved me wrong. Macromedia has successfully completed some essential steps in extending and maturing the ColdFusion Server Product.

First of all, they successfully completed the migration from p-code to Java (the way the ColdFusion server works internally). I truly believe the future will show this step as the correct, and only choice that they could have made. Second, they brought a large community to the product, which is very important to its long-term existence.

But all these accomplishments don’t even come close to the importance of the new features of MX Server. There are 3 things you MUST check out in this new version; your customers and your Web applications deserve it:

1. The new XML implementations and especially the XSLT support
2. Components and functions: a more object-oriented approach
3. The Flash Remoting Server extension, offering an incredibly easy implementation-to-use implementation of a rather complex technology that rocks the Web application world: Web services.

1. Why XML and XSLT?

Many attempts have already been made to separate the code from the layout. First we had HTML – formatting the content with a limited set of possibilities to achieve a nice layout. Then came style sheets – extended layout functionality on top of HTML-formatted content.

To separate the content from the layout completely we now use XML and XSLT. XML does not format content – XML only points out what the content, embedded in the XML tags. XSL does not contain any content – an XSL document is just a style sheet. It only describes how different types of content should be displayed.

We can apply the style sheet to the content in any place we like, server side or browser side (currently IE6 is the only browser fully supporting XSL 1.0 specs as approved by W3C, although most recent browsers offer a fairly good interpretation of XSL). Of course, with ColdFusion MX we want to parse server side, sending the properly formatted result to the browser.

A good XML/XSL parser also offers some conditional logic that is performed on the XML-formatted content. With Xqueries and Xpaths, we can limit the content to specific nodes, conditionally change the layout and even merge XML-formatted query results (a neat example is to compare books from 2 different online vendors, by joining them on ISBN number and price).

Or we could just let third parties decide what content they want to grab from our site and how to display it, by allowing them to refer our XML parser to their own XSL style sheet. CF MX has it all, and makes it very easy to set up and use.

Try it, play with it.

2. Components and functions

With Structures, CF offered us a way to combine all kind of variables into a new data type, giving us a place to store all the information our ‘object’ consists of, in a proper way. We could easily make an ‘Address’ object by creating an Address structure and adding keys like ‘Name,’ ‘Email,’ ‘Location,’ etc. to it. Still, we lacked some functionality: more specifically, the functionality of DOING something with the object. Sure, we could take our structure and use it in our template code anywhere, but nowhere could we describe what we intended to do with our ‘object.’ With Components, now we can.

If we define our Address object as a component, we can not only store our information in the appropriate places, we can also define what we want to do with this information – what actions are allowed to act on the information.

We can define a function that says: “Get me all the Addresses and return the name and email of each address.” We can define a function that shows a single Address in detail. We can define which fields we can edit, and how we can edit them. We can delete a address by creating proper functions for it. By accessing our Address ‘objects’ only trough these functions (in OOP languages we call them ‘methods’) we can completely determine all the possible interactions between our application and our Address object.

In addition to that, we can create new objects that extend existing objects and add new information and functions to them, allowing them to inherit all the variables, functions, logic and behaviour we already created. CF MX is not an object-oriented language, but this functionality certainly is a big step towards OOP behaviour.

3. Flash Remoting and Web Services.

MX doesn’t stop with components and functions. Maybe the most exciting feature of the new CF release is Flash Remoting Server.

What if we could use our components and functions not only in our own CF templates, but expose them to the Web and make them accessible for other applications, applications developed in other languages, maybe even in a client side environment? Now we can.
There’s a standardized way of making these components and functions available on the Web, allowing them to be accessed remotely. That technology is called Web Services. We make our Addresses (as an Address book) accessible by other, remotely hosted applications by making the Address book a Service on the Web.

The beauty of ColdFusion is that we don’t need to change a single line of code. If we define our variables and functions as remotely accessible in our components, the MX server automatically creates a Web service gateway to it. It’s as easy as that. And because Macromedia insisted on rocking our world completely, they provided a ‘Flash Remoting’ wrapper on the Web Services, making it accessible by Flash plug-ins running on the browser. This is pretty smart, since the Flash plug-in is installed on almost every browser out there. This means, we can retrieve and send information from within our Flash plugin to our web application real-time, without having to reload our web page. Awesome.

By now, you probably are hungry to taste all the goodies. There are comprehensive tutorials on Macromedia’s site, in the desdev section. In addition to that, Hal Helms wrote a nice article in this issue of ColdFusion Developers’ Journal. Check it out.

Certified Advanced ColdFusion 5 Developer

Focus on: coldfusion, content management / spectra , oracle.

Current projects: Writing a lightweight content management system (appframework), Kreynet IRC Network

http://www.marbie.net/

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles