Blog

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

(7)

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 http://ortus.svnrepository.com/svn/coldbox/coldbox/trunk or via https://secure.svnrepository.com/s_lmajano/coldbox/coldbox/trunk 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: http://www.robgonda.com/blog/index.cfm/2007/10/30/ColdBox-Beta-2-FlexAIR-Integration-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 http://www.busycode.com

Recent Entries

ColdBox 7.2.0 Released

ColdBox 7.2.0 Released

ColdBox, a widely used development platform for ColdFusion (CFML), has unveiled version 7.2. Packed with compelling new features, bug fixes, and enhancements, this release is designed to empower developers by boosting productivity, refining scheduled task capabilities, and enhancing the overall reliability and efficiency of application development. This article will delve into the key highlights of ColdBox 7.2 and elucidate how these advancements can positively impact developers in their daily coding endeavors.

Luis Majano
Luis Majano
November 20, 2023
Into the Box 2023 Series on CFCast

Into the Box 2023 Series on CFCast

Excitement is in the air as we unleash the highly anticipated ITB 2023 series exclusively for our valued CFCast subscribers – and the best part? It's FREE for CFCast members! Now is the perfect time if you haven't joined the CFCast community yet. Plus, we've got an incredible End-of-Year deal that's too good to miss

Maria Jose Herrera
Maria Jose Herrera
November 20, 2023
Ortus Deals are Finally Here!

Ortus Deals are Finally Here!

The much-anticipated Ortus End-of-the-Year Sale has arrived, and it's time to elevate your development experience! Whether you're a seasoned developer, a tech enthusiast, or someone on the lookout for top-notch projects, Ortus has something special in store for you. Brace yourself for incredible discounts across a wide array of products and services, including Ortus annual events, books, cutting-edge services, and more.

Maria Jose Herrera
Maria Jose Herrera
November 15, 2023