ColdFusion 9: Flex Improvements

With the release of the ColdFusion 9 beta I thought I'd share a few of the Flex integration improvements I've been checking out this week. First, ColdFusion 9 now uses Blaze DS to power Flex remoting and messaging. ColdFusion has had remoting support for several versions, but before CF 9 you had to install LCDS or BlazeDS to get Flex messaging. With the move to Blaze DS there is no longer an integrated LCDS Express installation option, so if you want RTMP or data services you will have to buy a separate LCDS license or install the free LiveCycle Data Services ES Single-CPU License version yourself. I know some people feel this is a loss but I'm pretty happy having messaging available out of the box, without the single CPU limitation.

[More]

CFEventGatewayAdapter and Selectors

Lately I've been doing a lot of work with Flex messaging using ColdFusion and BlazeDS. Recently I was trying to get message filtering working using the Flex Consumer component's selector property. After a few false starts I found that I just couldn't get selectors to work using either BlazeDS or LCDS.

[More]

BlazeDS Consumer Selector Gotcha

When working with Flex messaging, a Consumer component can filter the messages it receives using a selector. The selector uses SQL 92 syntax to filter against message headers, so if my messages contained a header named roomID I could write something like:

myConsumer.selector = "roomID = 1";

The problem I ran into today was that I wanted to filter on multiple values using an IN clause, however when I tried to do the following I got no messages:

myConsumer.selector = "roomID IN (1,2,3)";

Turns out that I needed to modify my IN statement to filter for string values as opposed to numeric values:

myConsumer.selector = "roomID IN ('1','2','3')";

This was a little confusing because I was able to filter on single values using numeric values, as in my first example above, but filtering on multiple values required string values. I'm using BlazeDS with ColdFusion, so I'm not sure if this is specific to my configuration, but if you run into issues trying to filter on numeric values using an IN clause, try using strings instead.

UPDATE: After further testing I'm not entirely sure that selectors work at all with the ColdFusion Event Gateway Adapter. I'm still trying to work this out, but right now the first example above doesn't seem to be working for me, even if I check for a string value. If anyone has experience using selectors with CF please let me know...

Flex Remoting to CFCs under a Fusebox 5.5.1 Application.cfc

I recently started using Fusebox again and one issue I ran into was that Flex Remoting calls to CFCs under my Fusebox application were not working. (The application in question used an extended version of Fusebox's Application.cfc.) To work around the issue I put the remote components under a different, minimal, Application.cfc which used the same name as my main applicaiton. Something like the following:

<cfcomponent>
<cfset this.name="myApp" />
</cfcomponent>

This fixed the issue, but I was still a little puzzled. It is well know that the Application.cfc onRequest method doesn't play well with Flex Remoting, but I looked at Fusebox's Application.cfc and thought it was handling the issue with the following code in onRequestStart:

<!--- ensure CFC / Web Service / Flex Remoting calls are not intercepted --->
<cfif right(arguments.targetPage,4) is ".cfc">
<cfset doCompile = false />
<cfset structDelete(variables,"onRequest") />
<cfset structDelete(this,"onRequest") />
<cfreturn/>
</cfif>

Well, today I had a little bit of time to look into this and it turns out that for Flex Remoting requests the targetPage is "/flex2gateway," not the name of the target CFC. It was a bit of a "duh" moment, because if you have ever looked at a services-config.xml file or watched Flex Remoting requests via a proxy like ServiceCapture then you know the URL used is something like http://localhost/flex2gateway. Anyway, to fix the issue I ended up modifing the Fusebox Application CFC code above to the following:

<cfif right(arguments.targetPage,4) is ".cfc" or findNoCase("/flex2gateway",arguments.targetPage) gt 0>
<cfset doCompile = false />
<cfset structDelete(variables,"onRequest") />
<cfset structDelete(this,"onRequest") />
<cfreturn/>
</cfif>

Now I no longer need to remember to add a custom Application.cfc for remote CFCs.

It is important to note that Flash Remoting can be configured to use any URL, but this at least covers the default configuration for ColdFusion.

Debugging Flex with ColdFire

Recently I went back to doing Flex work and one of the things I immediately missed was ColdFire. So I decided to take a look to see what could be done to get my favorite debugging tool working with CF powered Flex applications. Turns out it wasn't all that hard. First though, check out the video below to get an idea of what I'm talking about. (Sorry, no sound as I recorded this at work.)

[More]

ModelLocator Dependencies in Cairngorm

I'm new to Flex, but realizing the benefits of using a framework in a team environment I decided to give Cairngorm a try for my first real Flex project. I had heard some not-so-good things about Cairngorm from a lot of developers I know and respect, but I figured I had to see for myself. At first I didn't really see much wrong with the micro-architecture. Sure there was a lot of repetitive boilerplate, but I was using a code generator so it wasn't that bad. Things were going along pretty well, that is until I got about half-way through the project and began to work on the administrative interface for this application, which happened to be a separate Flex application. Well, it turns out the administrative application could have reused a lot of the main application's views, that is if they didn't have hard coded references to the ModelLocator all over the place. Most of the script blocks in my views started out with statements like:

[More]

Binding to Calculated Properties

A couple of weeks ago I posted about how I was using implicit getters in my model for calculated properties. This works great, but if you are calculating these values based on ArrayCollections you have to do a little extra coding to make sure changes to your ArrayCollection update your calculated value bindings.

[More]

Flex Data Binding

Yesterday Joe Rinehart blogged about using the ternary operator in Flex data binding. I was glad to see this post as I'm in the middle of my first Flex project and I find my self using this technique quite a bit. Here is just one example, which changes a text input's background color to red if it has a negative value.

[More]

Learning Flex

After about two years of threatening to learn Flex I'm finally doing it. I started by completing the "Adobe Flex 2 Rich Internet Applications" DVD-ROM course from Total Training. I won this a while ago at a CFUG meeting and have been meaning to get to it ever since. I have to admit, I wasn't sure how I'd like the format given that I usually learn by reading a book on a particular topic then experimenting, but I liked the course. And I know what your thinking, "Flex 2?," but from what I can tell the basics of Flex haven't changed much from Flex 2 to Flex 3, so I found the course very helpful. I'd even recommend it to someone looking to learn the basics of Flex in a hurry.

[More]

on AIR Bus Tour

I just got home from the on AIR Bus Tour and I have to say that Adobe has done a great job with this tour. The venue was awesome (The Franklin Institute here in Philly), the beer was cold, and the presentations were informative, at least for an AIR newbie like me. I'll admit that haven't had time to look into AIR so I wasn't really getting the hype. However, after tonight's presentations I'm pretty excited about the possibilities... Plus I won a copy of Flex Builder 2 with Charting, so I guess I have no more excuses for not learning Flex.

More Entries

BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.