Rob Gonda's Blog

Cairngorm 101 presentation and files

I presented a session on Cairngorm last week at CF.Objective() and explained all its elements, design patterns, event flow, levels of abstraction, and walked-through steps on a simple example.

You can find my slides and examples -- MVC1.001, 002, and 003 -- and each adds a little more functionality. MVC1.001 just displays a form, 002 adds a click event, fire an event, traps is in the controller, executes a command, updates the model, and 003 also uses a business delegate and a service locator. To run the files simply extract in a folder, open flex builder, import a project, and point to the MVCX folder. I did not include the Cairngorm source files, so depending on your preference, either copy them into your project, or add the SWC to your classpath library. You can download the latest version from labs. Just in case, right click the project, click properties, Flex Build Path, Library Path, click Add SWC, and point to the cairngorm.swv binary that you downloaded from labs.

Here's an overview of the differences in the examples so your can follow along:

MVC1.001
* Cairngorm MVC with views only
* No events, commands, model, VO
* Main file loads service, controller, and viewlet

General flow:
* Main shell loads business, control, and view
* View displays login box


MVC1.002
* MVC1.001 plus
* Cairngorm MVC with model, view, controller
* No business delegate or service locator
* Main file loads service, controller, and layout view
* Added LoginCommand, and LoginEvent
* Control registers event
* Added Login model in model locator
* Model implements state
* View contains view stack binded to state
* Command immediately approves login attempt and update model

General flow:
* Main shell loads business, control, and view
* View displays layout with view stack
* View stack is bound to the model and displays login box by default
* User clicks login button and triggers loginUser()
* Function creates a LoginVO to hold the login data
* Function creates a LoginEvent and passes the LoginVO
* Function dispatches the event
* Controller traps the event and executes the LoginCommand
* Command updates the login model and workflow state in model
* Viewstack is bound to workflow stats and update view


MVC1.003
* MVC1.002 plus
* Cairngorm MVC with model, view, controller, business delegate, and service locator
* Added LoginDelegate
* Services.mxml contains RPC, but it's commented out for demo purposes

General flow:
* Main shell loads business, control, and view
* View displays layout with view stack
* View stack is bound to the model and displays login box by default
* User clicks login button and triggers loginUser()
* Function creates a LoginVO to hold the login data
* Function creates a LoginEvent and passes the LoginVO
* Function dispatches the event
* Controller traps the event and execute the LoginCommand
* Command initializes the LoginDeletate to talk to the server
* LoginDelegate gets the loginService from the service locator (commented for demo purposes)
* LoginCommand invokes thes login function in the LoginDelegate
* LoginDelegate invokes the login function in the loginService (commented for demo purposes)
* LoginDeletate calls the loginResult which randomly logs the user in (only for demo purposes)
* Service call returns and calls the onResult function in the command
* Command updates the login model and workflow state in model
* Viewstack is bound to workflow stats and update view

I'll explain all this and much, much, much more in my 8h Flex Intensive for ColdFusion Developers at CFUnited.

Related Blog Entries

TrackBacks
There are no trackbacks for this entry.

Trackback URL for this entry:
http://www.robgonda.com/blog/trackback.cfm?8CBB2305-3048-7431-E4FCFCB412518638

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
This blog is running version 5.9.003. Contact Blog Owner