ColdBox Beta 2: Flex/AIR Integration

Luis Majano October 15, 2008

Spread the word

Luis Majano

October 15, 2008

Spread the word

Share your thoughts

Well, my secret project is out of the bag today. I have been working in embedding a remote proxy into ColdBox in order to enable remote applications like Flex and AIR to communicate with ColdBox and provide an event model for our model. If that makes sense!! Well, so what do we get? This feature lets you create an event driven model that can easily be called from any flex/air application. Not only that, but you can reinitialize the entire application, get settings, and yes, announce custom or core interceptions. You can create custom interceptor chains for your model that can be executed asynchronously when a user hits a save record button for example. The possibilities are endless. Not only that, but this enables you to actually create two front ends using the same reusable ColdBox and model code. The code is the same, you create event handlers, you interact with a request collection, with core and custom plugins, but you don't set views or layouts because the framework is now a remote framework for your model. So what do you do, well, return data, arrays, xml, value objects. Anything, right from withing the event handlers.

//Just return an array var myArray = ArrayNew(1); myArray[1] = "Hola"; myArray[2] = "Hello"; myArray[3] = "Bom Dia"; myArray[4] = "Ciao"; myArray[5] = getMyPlugin("date").getToday(); //Log my call getPlugin("logger").logEntry("information","My intro arrays called from flex."); return myArray; As you can see from my event above, my event is called "getIntroArrays", which uses a plugin to do some logging and return an array to flex. So simple, what is even better is the following: What is this? Well, the event context object now has a new method called: "isProxyRequest()" which let's you know that the ColdBox proxy is executing the event. With this you can run alternate code or eliminate presentation. WOW!! That simple!! What is even more impressive is that your coldboxproxy component is actually an inherited proxy. So you can override the proxy or customize it according to your needs. You can intercept proxy calls, create your own custom proxy methods and tap into the framework as you see fit!! You have the flexibility to do so. Here is a sample flex code setting up the RemoteObject Here is a sample of the call: /* GET TEST ARRAY */ public function handleArrayResults(event:ResultEvent):void{ aResult=event.result as Array; } public function getRemoteArray():void{ coldboxProxy.addEventListener("result",handleArrayResults); coldboxProxy.process({event:"ehFlex.getIntroArrays"}); } As you can see, you call the process method with the event you want to execute. If you would like to pass in a whole bunch of params then you do the following: var params:Object = new Object(); params.event = "ehFlex.getUsers"; params.user_id = txt_username.text; params.password = txt_password.text; coldboxProxy.process(params); And there you go, you send in the params and execute the event. Well, I hope this is a good teaser of what you will be getting in beta 2 of ColdBox 2.5.0. The requirements for having a Flex/Air enabled application are very minimal, just by simple returning results from your handlers and setting a hard coded AppMapping variable, so coldbox can parse your application. I will be posting much more on this topic as beta 2 time arises. Ohh by the way, the code is in SVN with a full Flex/ColdBox application. Enjoy!!

Add Your Comment


Oct 27, 2007 19:35:43 UTC

by Russ Johnson

Luis, this is fabulous! I love the idea of using existing model code in a ColdBox application for a Flex front end. This is great! I cant wait to start playing with this.

Oct 27, 2007 19:44:45 UTC

by Sana

I don’t have words to say thanks for such a great development toolkit you are offering. Its toooooo awesome man: you are really rocking! Anybody you dare to test new incredible features can download bleeding edge code from SVN: svn co or via username: nightlybuild pass: nightlybuild Again thanks so much for these great features. You made the development so easy-peasy; so nobody would have excuse that coldbox does support RIA. I think coldbox is a must have a tool like cfeclipse

Oct 27, 2007 20:37:29 UTC

by Sean Corfield

I demo'd Blackstone (CFMX7) at Fusebox 2004 and showed a proxy for Fusebox that worked like this but I didn't recommend people did it because it really just forced the Flex/Fusebox communication to use a query string, albeit as a method call. However, it does appear to be a very appealing approach to a lot of people and that's why I started Edmund recently... Maybe I'll have another look at ColdBox now you've added this and see whether it's even worth me continuing with Edmund!

Oct 27, 2007 20:43:16 UTC

by Luis Majano

Hi Sean, The proxy works by method calling via a remote object or treating the proxy as a webservice. So you can call the different methods on it. The idea was to use the "onMissingMethod" approach, but since we still have to support cf7, the proxy is based on cf7 capabilities. However, the release will include also a cf8 proxy, which will be based on cf8's capabilties. I truly welcome your input, and check out the sample app. Maybe we can come up with more goodness for the proxy.

Oct 28, 2007 12:15:34 UTC

by Sami Hoa

Well done Luis. You keep pushing things to the limit. Keep it up!

Oct 30, 2007 21:38:51 UTC

by Rob Gonda

Ok, I give up. I've been trying to comment for a couple of days and it fails silently. Follow this link to read my comments:

Apr 18, 2008 02:18:19 UTC

by Andychou

Need 3 Flex engineers in New York City: 1. You have to be living in New York City for now. 2. Work part time or full time with us. 3. Good at Adobe Flex technology. 4. Please contact us for other requirement and details. Busycode Inc. is a top Adobe Flex shop who develops Flex/AIR applications for clients. For more info, please visit

Recent Entries

Hackers demand a ransom to restore data from my ColdFusion web applications!

Hackers demand a ransom to restore data from my ColdFusion web applications!

Hackers demand a ransom to restore data from my ColdFusion web applications!

Unfortunately, we often hear this message from clients who thought it would never happen to them... until it did. Some believed they could delay the expense of Implementing ColdFusion security best practices for one year, while others were tempted to put it off for just a few months. However, in today's rapidly evolving digital landscape, the security of web applications, including ColdFusio...

Cristobal Escobar
Cristobal Escobar
April 16, 2024
Ortus March Newsletter

Ortus March Newsletter

Welcome to Ortus Solutions’ monthly roundup, where we're thrilled to showcase cutting-edge advancements, product updates, and exciting events! Join us as we delve into the latest innovations shaping the future of technology.

Maria Jose Herrera
Maria Jose Herrera
April 01, 2024
Into the Box 2024 Last Early Bird Days!

Into the Box 2024 Last Early Bird Days!

Time is ticking, with less than 60 days remaining until the excitement of Into the Box 2024 unfolds! Don't let this golden opportunity slip away; our exclusive Early Bird Pricing is here for a limited time only, available until March 31st. Why wait? Secure your seat now and take advantage of this steal!

Maria Jose Herrera
Maria Jose Herrera
March 20, 2024