There are some excellent Cairngorm 2 examples on the web but none that really covered the Flash Remoting and the Master/Detail “bean” created when you use the ColdFusion/Flex Application Wizard in Flex Builder 2. I wanted to create a very simple example that basically used the same ColdFusion components (CFC) created when you use the ColdFusion Application Wizard. I received some really good advice and encouragement from Tim Hoff on Flexcoders as well as examples from the community.
Jesse Warden (Jexter) posted an example using Flex 2 Webservices and Cairngorm 2. Benoit Hediard’s posted a PhoneExample application that used Flash Remoting. Alex Uhlmann has several good examples that show you how to use change the state of your application with Cairngorm 2. Of course the ultimate example is the CairngormStore example posted on Adobe Lab’s along with the series of articles by Steven Webster of Adobe Consulting and the store example code posted by Andy Rayne.
The example is simple and the implementation could probably be changed a bit. For example, the current example passes an Value Object to the detail view. When the detail view updates, it also updates the reference of the Value Object in the VO array at the same time (DataGrid in the Master view). I also dispatch an event when any VO object is successfully updated to refresh my Master view. I suspect that I would just work directly with the array of VO’s directly. However, the examples I have reviewed all have little differences, this may be just to due to preference. Maybe one day I can discuss this directly with someone from Adobe Consulting, to really understand the best practices when using the Cairngorm framework.
I will say this, the time it took to go from idea to final product (although very basic) was simple when you use the framework. I could see how the Cairngorm architecture can really speed up development time and also make a solid and scalable structure for your application.
Benoit Hediard wrote on FlexCoders:
Concerning this issue, our best practice is to implement a clone() method to all the VO classes. In the command that open the popup, you clone the VO in order to eliminate any binding references. When the cloned VO is updated (or when the updated VO is returned by the server), you could update the collection referenced as a dataprovider instead of refreshing the entire master list (but only if you use an ArrayCollection, if you use a simple Array, your bindings won’t be updated).
I have updated the example to reflect Benoit’s suggestions, everything is working great now!