Java Coldfusion • Computer Engineer
ColdBox Beta 2: Flex/AIR Integration
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.
<cfargument name="Event" type="coldbox.system.beans.requestContext">
<cfscript>
//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;
</cfscript>
</cffunction>
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:
<cfset getPlugin("JavaLoader").setup( listToArray( ExpandPath("../includes/helloworld.jar")) )>
<cfelse>
<cfset getPlugin("JavaLoader").setup( listToArray( ExpandPath("includes/helloworld.jar")) )>
</cfif>
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
id="coldboxProxy"
destination="ColdFusion"
source="coldbox.coldboxproxy"
showBusyCursor="true"
fault="Alert.show(event.fault.message)"
>
<mx:method name="process" />
<mx:method name="getSetting" />
</mx:RemoteObject>
Here is a sample of the call:
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:
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!!



Anybody you dare to test new incredible features can download bleeding edge code from SVN:
svn co http://ortus.svnrepository.com/svn/coldbox/coldbox...
or via https://secure.svnrepository.com/s_lmajano/coldbox...
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
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!
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.
Follow this link to read my comments: http://www.robgonda.com/blog/index.cfm/2007/10/30/...
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