April 17, 2008

Flex, MVC, Cairngorm and Universal Mind Extensions

Filed under: cairngorm, cool, dev, education, flex, mvc, tip — michaelangela @ 8:08 pm

This podcast with Thomas Burleson probably has the best description of MVC with Flex, why to use Cairngorm, challenges of using Cairngorm, why to use the universal mind extensions, the problem of view locators and how to work with those, etc. Good stuff. I wish there was a transcript of this.

UMEvent, UMCommand, Callbacks, and other goodies galore. Cairngorm is really, really good. It’s very lightweight. This just takes it further. Now I just need to understand how to use them. 🙂 But that’ll come later.

Another interesting bit is about the centralized error handling… oh good stuff.

Hmm… webservice is far slower than remote objects. And if they fail,
they can fail silently. Ah, that’s WSDL services. Interesting stuff.

Sequences in Cairngorm is quite different than sequences in UM Cairngorm… wow… nice stuff. It’s giving you quite a bit of flexibility: firing sequence of events and commands.

Another bit about refactoring is mentioned, i.e. every use case in Cairngorm has a command/event. It’s definitely workable but it can get tedious. The UM extensions help with that as well.

Download the file and listen to it with Quicktime Player and bump the speed up to like 175% to save some time. 🙂

The Flex Show: The Flex Show – Episode 41: Universal Mind Cairngorm Extensions w/ Thomas Burleson


April 11, 2008

Universal Mind Cairngorm Extensions

Filed under: cairngorm, cool, dev, education, flex, mvc — michaelangela @ 4:18 pm

There are several issues I have had when developing with Cairngorm. It gets better with time as you work around the issues, but you have to “work around them”, as opposed to working within the system constraints. The constraints are good. They give form and function. But there are some headaches… certainly no offense to the Cairngorm developers as it is a phenomenal piece when you think about what went into it.

Well, others agree that there is room for improvement. And this bit from Universal Mind may help with a lot of those things. Good stuff coming.

flexcairngorm – Google Code

Universal Mind has extended the
“classic” Adobe 2.2.x Cairngorm version to provide many productivity
and maintenance enhancements. Those extensions have now been
open-sourced – with BSD licensing – to the Flex and Flash developer

The Cairngorm Extensions are summarized below. Each link will provide details and examples of the specific extension:

  1. Events
    • Built-in support to transport responders for direct view or business logic callbacks.
    • Implementation of AnnounceFaultEvent to allow business logic to centralize error reporting and logging.
    • Implementation of EventGenerator to allow developers to automate dispatching of sequences of events.
    • Events now should self-dispatch… for direct deliver to the business/controller layer.

2) View Notification

  • Built-in framework support to allow views to request direct notifications when buisness events respond.

3) FrontControllers

  • SubControllers are available so modules implemented with
    sub-MVC and dynamically aggregated and used within a global MVC
  • Improved error checking
  • Ability to easily register a Function callback for any business event

4) Command Implementation

  • Base class implementation
  • Enhancements to support aggregation of event-business logic within a single Command class.
  • Support for the optional view notifications
  • Best practice to deprecate Command sequencing

5) Delegate Implementation

  • Base class implementation
  • Support for easy queue of delegate calls
  • Improved support for WebService use and WSDL errors
  • Best practice to allow easy data transformations
  • Best practice to hide multiple server calls

6) ServiceLocator

  • Configure services (RDS) at runtime
  • Configure timeouts of HTTPService and WebService

April 4, 2008

Cairngorm, Flex and MVC

Filed under: cairngorm, dev, education, flex, mvc — michaelangela @ 4:43 am

Cairngorm helps when you’re wanting to know how to structure things. There are other options, especially as you start actually understanding the language. 🙂 PureMVC is an alternate framework. Then Flexygen has a simple MVC sample… without using Cairngorm. It’s not that Cairngorm is bad! It’s the de facto standard framework for Flex (right now at least). But sometimes it feels like you’re fighting it a bit… at least for those who are still learning like me. These are just some things to keep in mind.

Up next is Practical Patterns in Flex which also offers another possibility. I’ll have to look at it in more detail to understand it more though… I’ll save that for another day!

joeberkovitz.com » MAX 2007 in Barcelona: Talk Materials Online

A presentation called Practical Patterns in Flex, which I adapted from Jim Echmalian’s
talk at 360Flex earlier this year. This features a brand new take on
the Model-View-Controller-Service architecture, and highlights the use
of specific design patterns to remedy problems of encapsulating
responsibility, dealing with asynchronous operations, and gaining
access to the “right” controller without using messy singletons. I put
together a working sample application in source code form that accompanies the talk.

March 31, 2008

Getting Cairngen to work with Eclipse and Tiger

Filed under: cairngen, cairngorm, eclipse, tip, tool — michaelangela @ 11:06 pm

Thanks to Darren who added some notes on it, there may be hope yet! (I copy things things here to my blog in case the original sources disappear as many others have done… :-()

And Darren, yes it did help very much!

Eric Feminella: Solutions Architect, Rich Internet Applications » Blog Archive » Cairngen 2.1

For anyone interested, I’ve worked out how to get Cairngen running
on Tiger. It probably works for Leopard too. It wasn’t easy as there’s
no (official) JRE 1.6 available but now I’ve got there, it’s reasonably
straightforward. You just have to add BSF, Rhino and Commons-Logging
jars to your Ant classpath. Like so:

1. Download and copy bsf.jar and js.jar to your Ant lib directory. Get them here:


2. In Eclipse->Preferences->Ant->Runtime->Classpath, add
the 2 jars above (Add External JARs button), as well as
org.apache.commons.logging._*.jar (which should already be in your
Eclipse plugins directory). I’ve added them to Ant Home Entries which
works for me.

That’s really all there is to it. Then, as Eric says, you have to
run the appropriate targets in your Ant build file if you want to
create delegates, events, vo’s, etc. I couldn’t find an explanation as
to the best way to do this so I just added the targets to line 63 of
build.xml so it’s now:

depends=”log, create-model-locator, create-front-controller,
create-service-locator, create-multiple-sequences-include-delegates,
create-multiple-value-objects” />

I hope this helps.

Starting Eclipse with an alternate VM

Filed under: cairngen, cairngorm, eclipse, java, tool — michaelangela @ 10:29 pm

So I was trying out the Soylatte Java VM to get it to work with Eclipse so I could use Cairngen on a 10.4 Mac. I got an error after working with some Eclipse configurations so that Eclipse started with errors and didn’t allow much work. However starting from the command line (/Applications/eclipse/eclipse) got me back. I can also set the VM I want to use with the -vm argument. (Side note, I can use Scribefire’s “Custom HTML” option to insert <code> tags where needed it seems!)

Java Runtime Environment (JRE) – How to change the default JRE when there are several version of JRE in Sys

I recently installed Oracle 9i client on my new box
and now Eclipse will not start. I get an error

You can set the path to your VM in the eclipse start command:
eclipse.exe -vm <path-to-your-javaw.exe>

eclipse.exe -vm c:\program files\java\jdk1.5.09_09\bin\javaw.exe

Another way is to locate the VM with your path environment. Set the variable JAVA_HOME to the root path of your VM installation. Update your path settings and remove all occurences of java. At the end add the following: %JAVA_HOME%\bin
Now delete javaw.exe and java.exe from your windows\system32 directory. They’re not needed, because they are in your path.

So all java programs are in the path. To change the VM you only need to change the JAVA_HOME variable.

Cairngen, Eclipse and “Unable to load a script engine manager”

Filed under: cairngen, cairngorm, dev, java, tool — michaelangela @ 9:16 pm

I need to add a bunch of functionality and I really want to automate the file creation so I just started trying out Cairngen. I got this “unable to load a script engine manager” error. Fortunately I had just checked my Java VM version (default Mac OS 1.5) and according to this post I need at least JRE 6. Let’s see now… hrmm… Java on a Mac is a little trickier than I thought… distressing

Eric Feminella: Solutions Architect, Rich Internet Applications » Blog Archive » Cairngen 2.1

  1. Leif Wells UNITED STATES Says:

    November 19th, 2007 at 10:46 am

    Eric, I am trying to use Cairngen 2.1 in FB 3 beta 2 (stand-alone) and getting an error:


    C:\…\build.xml:373: Unable to load a script engine manager (org.apache.bsf.BSFManager or javax.script.ScriptEngineManager)

    Have you seen this before? Is there a software update I need to install? If so, which one?



  2. eric UNITED STATES Says:

    November 19th, 2007 at 11:59 am

    Hey Lief,

    You need to upgrade to JRE 6. First download and install at: http://www.java.com/en/download/manual.jsp

    Once you have upgraded the Java Runtime, restart Eclipse and from
    the toolbar select Windows > Preferences > Java (expand) >
    Installed JREs > Add > Browse (browse to Java Installation and
    select latest JRE). Click OK.

    Restart Eclipse and you should be good to go. Let me know if you have any problems.

    – Eric

Cairngen moving to Google Code

Filed under: cairngorm, dev, education, flex, tool — michaelangela @ 8:23 pm

I use Cairngorm. It’s main strength is making sure you put code where it should go. It goes by the MVC mantra which, in and of itself, is really good. The problem? To add one new capability, you sometimes have to add… I forget how many new class files:

“Hmm… need a button here to do X… ok… we need XEvent, XCommand, XController, XDelegate… *creating files* *doh typo!* *editing files* *doh!* *a few more ‘doh!’s* OK. Good.”

Cairngen aims to replace that problem (and a few others) by allowing you to generate the files in one go. I haven’t tried it yet but maybe now is the time?

Eric Feminella: Solutions Architect, Rich Internet Applications » Blog Archive » Cairngen Project moved to Google Code!

In order to provide a solid foundation to help facilitate a
collaborative Open Source initiative for the Cairngen Project I have
decided to move the project to Google Code.

Moving Cairngen to Google Code
allows for a number of significant development benefits for the
Cairngorm Community. This includes regular development updates, access
to all releases, availability of all source code revisions, better
documentation, defect lists, feature requests and much more.

Cairngorm and views responding to server side events

Filed under: cairngorm, education, flex — michaelangela @ 6:26 pm

I’ll have to dig up the links for this as a reference. But I started an app in Flex. I wanted a good framework to work with to help me organize the code, get some “best practices”, etc. I chose the then standard Cairngorm currently hosted at Adobe. Everything was happening client side so all was good. That was because with Flex, you can use data binding. That means your user interface elements can simply be “bound” to a certain bit of data. When the data updates, the UI element updates, automatically. That’s cool.

However I started to add server side processing. UI controls mapped directly to data, even data processed on the server side, is still updated automatically. However, what if I want to notify the user that data on the server has finished? How do I notify different UI elements about such things as “your data is saved”, “your data is NOT saved”, etc.?

Linking that sort of data becomes hard to do, and also hard to maintain. I seemed to be at a loss of what to do. This is where the reference links would come in. There was actually quite a bit of discussion about this and, in the end, what I needed, or at least what I concluded, was actually not recommended for Cairngorm.

In Cairngorm, you have models and you have views. (You also have controllers to complete the MVC pattern.) When your model changes (meaning your data changed), your views which are bound to the model update. This doesn’t leave room for UI notifications, etc. The pattern I found that I was after is called ViewHelpers or ViewLocator. Basically it’s a way to wire your views to listen for events for updates, specifically for user notifications.

There was even a good post about why you should just add responders to a Cairngorm event so that the view can be notified directly as a callback on that event. That’s good… except it makes the assumption that the only view interested in that event is the one that triggered the event. That’s not always the case.

I hit this because I wanted to do drag and drop from one Flex UI component to another. When the user drops the object, an event is fired to save data to the server. The originator of the event though was the not the view I wanted to update. I eventually did find ViewLocator/ViewHelper patterns to use, which helped tremendously, even though others disagree with the implementation.

Interestingly enough, a newer Flex framework called PureMVC doesn’t have these issues. The idea of any view being able to be notified by any event is assumed. If I have time, I will try to learn that system as it seems to be closer to the way I think… or perhaps how I want to think. 🙂

The following link has a good discussion about Cairngorm in general… just here for my own reference.

Flex and Flash Developer – Jesse Warden dot Kizz-ohm » Blog Archive » Cairngorm vs. Joe Berkovitz’s MVCS

Blog at WordPress.com.