Home  >  Development  >  blogs

ColdFusion and RIA Development - Part 2

| | Comments (0)
AddThis Social Bookmark Button

In my last post, I discussed how ColdFusion aids RIA developers, both Flash/Flex as well as AJAX developers. I focused on serving data up to RIA consumers. In this entry, I'm going to discuss other Ajax features, most of which help out on the front end of your web site, an area ColdFusion has traditionally stayed away from (which makes sense as a back-end development platform).

The first area I'll talk about are the new UI controls. These UI controls include: Menus, Pods (think fancy boxes), Grids (tables with pagination and sorting), tabs, windows, trees, tooltips, and other controls. All of these UI elements make use of AJAX libraries from Yahoo and Ext. But to the CFML developer, they are easy to use. So for example, to include a tabbed-based layout on your site, you can simply do:

<cflayout type="tab" tabheight="200">

<cflayoutarea title="Tab One">
<p>
This is the first tab.
<form>
Name: <input type="text" name="name"><br />
Email: <input type="text" name="email"><br />
<input type="submit">
</form>
</cflayoutarea>

<cflayoutarea title="Tab Two">
<p>
This is the second tab.
</p>
</cflayoutarea>

</cflayout>

As you can see, there isn't a lick of JavaScript here, but when rendered, ColdFusion will automatically include all the necessary JavaScript libraries it needs. The other UI controls are as simple to use, and a JavaScript API can be used for further control.

Another useful feature is the binding system. As you can guess, bindings let you link controls together and let you bind controls to HTTP-loaded content. What do I mean? Consider this simple example of the pod control:

<cfpod title="Pods with Ajax content" width="300"
height="200" source="content1.cfm" />

The title, width, and height attributes do as you would guess they do. The source attribute is what I want to focus on. When loaded, the pod will make an HTTP request to content1.cfm to load the contents of the pod.

Here is another powerful example:

<cfselect name="mediaid"
bind="cfc:art.getMedia()"
bindonload="true"
value="MediaID"
display="MediaType" />

This creates a HTML select control where the items are bound to a CFC. Upon loading the page in your browser, an HTTP request is made to the Art CFC, getMedia method. That method returns a simple query of data. ColdFusion handles converting the query to JSON as well as handling parsing the response and filling the drop down. Easy as pie.

The last feature I'll discuss is one of the most powerful things I've seen yet built into a web development platform. The <cfajaxproxy> tag creates a connection between client-side JavaScript code and CFCs. Ok that sounds simple enough, but what do I mean? Imagine a simple component that has a method, getTime, that returns the current time. I want to include that CFC's method result in my Ajax-based application. Normally that would require me loading a custom Ajax framework, writing code to make the request, and then handling the request. The <cfajaxproxy> tag simplifies all that. I first define the connection:

<cfajaxproxy cfc="timeService" jsclassname="timeProxy">

Then I can create a JavaScript object:

var myProxy = new timeProxy();

and to get the time, I simply do:

theTime = myproxy.getTime();

Behind the scenes, ColdFusion has created all the JavaScript necessary to create a client-side proxy to my remote CFC methods. I can run the code like it was native JavaScript code.

So this is just a brief overview of what ColdFusion 8 has in terms of RIA development. There is a lot I'm leaving out, but hopefully it gives people a good idea of the level of support Adobe added in the last version of ColdFusion. As I said in the first entry, I'd really love to open a discussion about how the other major platforms (PHP, Rails, .Net) support RIA. I don't want this to be a 'my platform is better than your platform' fight, but I'd truly like to know what the other products do to help RIA developers.

Comments

Leave a comment


Type the characters you see in the picture above.

Tag Cloud

Related Books

Development Series

Get an overview of the tools and technologies that work together to allow developers to build Rich Internet Applications (RIAs) quickly and easily.

Anatomy of an Enterprise Flex RIA

Recent Comments

Archives


 
 


Or, visit our complete archive.  

About This Site

Welcome to the premiere community site for all things RIA sponsored by O'Reilly Media and Adobe Systems Incorporated.

About Us
Meet the Experts
Meet Our Contributors
Send Us Feedback