Uncategorized
Using Reactor with Flex 2
A while back I posted on my usage of ARF!,ColdSpring and Reactor with flex 1.5. I promised to talk about how I was using it and what I was doing. Well I promptly got sidetracked and it never happened. So to make up for that I wanted to talk about what i have learned about using Reactor with Flex 2.
A little background first. I am working with reactor from svn. I dont have any idea when the last zip file was released but my codebase is current. And as such some of the things I might mention may not be in the latest public zip and also require that you have a small understanding of Reactor.
The most prevelant example of CF and Flex 2 integration right now is Ben Forta’s Phone selector example. In this example our Flex 2 gui connects to a remote service object. That remote service object has a getProjects() method which returns an array of Phone objects. His Phone.cfc is generated from the nifty RDS eclipse plugin that Adobe is working on. In that respect the steps he went through are very similiar to what we would do in reactor. Except we wouldnt do our code generation ahead of time.
If this example was to be done in reactor then our remote service object would create an instance of our reactor factory, use it to create an iterator for our phones, then our iterator to loop through our phone objects.
You might think this is enough, but in truth returning these objects would get us no data. In reactor our data is actually containd in Transfer Objects. So we need to return the actual TO of our Phone object. Right now the easiest way to get that data is to create a getTo method inside our Record Object. This file will be created in the location we specify for “mapping” in our reactor config. The function in its simplest form might look like:
With that in our Phone record object our getPhones() method might look like ( we like hypothetical code ):
With this we now return actual data now to our flex gui, so all we need to do is update the [RemoteClass] compiler binding in our Phone.as object. Depending on how you set your reactor “mapping” in the config. Mine looks like:
[RemoteClass(alias="phoneDemo.data.To.phoneTomysql4")]
This is the basics of what you need to get your reactor code working with Flex 2. Stay tuned for a new sample project i am working on which uses Reactor, ColdSpring and Flex2.
[UPDATE]
Ok, so I forgot one thing. You also need to add the cfproperty tags to your TO that is being returned. The trick is to make sure that the cfproperty tags are defined in the same order as the instance properties of your AS object.

