After talking to a friend about frameworks and so forth. He mentioned
the Swiz framework after incorporating it in a project he was currently working on. Being a dedicated Cairngorm guy I couldn’t say
that I had looked at Swiz before but from what I had heard it sounded like something that may be useful in the future. I had also thought it would make a great name for a cocktail “Excuse me bartender fetch me another Swiz”…
Category: Cairngorm
category
Transfer ORM and Flex
Recently I’ve been working on a project to deliver something that was more proof of concept which in a business sense building something in a relatively short time frame.
I decided to develop the front end with Flex 3 and the back end with ColdFusion 8 using the flex remoting classes to connect the two together. Having chatted recently to a couple of fellow developers there was a consensus among them that documentation for connecting both ColdFusion and Flex was underdone and that it could possibly be the Achilles heel in using CF as the server side technology.
I myself haven’t found any issues in connecting the two together. Sure there are a couple of files that need to be configured everything hangs together harmoniously. Compared to other technologies like webOrb and amfPHP it’s relatively painless.
Transfer
Due to the nature of the beast I needed something that would look after my CRUD methods on the server side. I didn’t want to have to spend time hand writing this code and having seen a couple of presentations on Transfer it made sense to use this as my ORM. For those of you that don’t know about Transfer it’s an ORM for Coldfusion. It allows you to create your object relational mappings of your database allowing you to perform simple to complex database transactions. More information on Transfer can be found here. I then used Transfer to plug into a lightweight CF framework that I had custom built some time ago that I normally use for Flash and Flex development using the facade pattern to expose the required services.
Other Code Generating Tools
I also use the Illudium PU-36 Code generator developed by Brian Rinaldi to help create the ORM mappings and services and gateways for the required objects. You can download and read more about this code generator here on the RIAforge website.
These two great tools allow me to create the server model fairly quickly allowing to spend more time planning and creating the UI.
Setting up Transfer to work with Flex
You first need to setup your objects on the client and server. If you are using Cairngorm on the client these would be your Value Objects. On the server these would be your Objects that your Transfer objects would be extending.
I’ll be using the blog application that ships with Transfer as the examples. Hopefully I’ll be able to post the running application once I’ve completed it.
In your flex value object.
package com.riality.tblog.vo
{
import com.adobe.cairngorm.vo.IValueObject;
[RemoteClass(alias="tblog.com.PostVO")]
[Bindable]
public class PostVO implements IValueObject
{
public var IDPost:String = "";
public var Title:String = "";
public var Body:String = "";
public function PostVO()
{
}
}
}
The important part here is your RemoteClass metatag. This must correlate to the Value object in your CF framework. This is done by extending your transfer object inside your Transfer.xml to an Object that can bind to your flex value object.
Example inside your Transfer.xml
Dispatching Events with Cairngorm 2.2.1
While trawling through the CairngormEvent.as I noticed the distpatch() method which in essence calls the same code that was needed in the previous versions of Cairngorm.
Pre Cairngorm 2.2 example
var userVO : UserVO = ModelLocator.getInstance().userVO;
var event : LoginChangeEvent = new LoginChangeEvent(LoginChangeEvent.LOGOUT_EVENT,userVO);
/* dispatch the event */
CairngormEventDispatcher.getInstance().dispatchEvent( event );
Latest example
var userVO : UserVO = ModelLocator.getInstance().userVO;
var event : LoginChangeEvent = new LoginChangeEvent(LoginChangeEvent.LOGOUT_EVENT,userVO);
/* dispatch the event */
event.dispatch();
It just saves having to import the CairngormEventDispatcher and typing those extra characters. Which can save a lot of time if you’re a chicken pecker typist 🙂