Chen Bekor performed a real service when he created a modified CairngormStore example that decoupled the application from its data services, replacing them with mock objects, back in late 2006.

This version's beauty is that it can be installed and run easily. It is extremely helpful when learning Cairngorm to have a working version that you can play with and step through in your debugger.

I've just upgraded the example for Cairngorm 2.2.1 and Flex 3. Below is a list of the changes I've made. You don't need to read these if you just want to explore and learn. Just download the .zip file, unzip, import into FlexBuilder 3, and run. If you'd like more detailed instructions Chen was kind enough to include some in a readme.txt file in the project folder.

Here's the file:

Chen Bekor's ModifiedCairngormStore_2_2_1.zip

Change Log

I'm including this list of changes a) for the record, and b) because these steps will probably also be needed for most any Cairngorm application that you're updating from 2.1 to 2.2.1.

  • I replaced the Cairngorm SWC with source code so that you can step through both the example code and the framework's code in your debugger.
  • I replaced the first three lines of com.adobe.cairngorm.samples.store.business.ServiceLocator:
Replaced code:

xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:cairngorm="http://www.adobe.com/2006/cairngorm">

Replaced with:

xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:business="com.adobe.cairngorm.business.*">

  • I modified the last line in the same file so that it uses the same "business" namespace.
  • I added the following folders to the project root folder:
    • [project_root]/src/
    • [project_root]/locale/en_us/
  • I moved the following files and folders from [project_root] to [project_root]/src/ as this is the standard Flex 3 source code location:
    • Main.mxml
    • cairngormstore.css
    • /assets/*
    • /com/*
    • /data/*
  • I placed this file into the [project_root]/locale/en_us/ folder I just created: CairngormMessages.properties
  • I went into Project | Properties | Flex Build Path and added "locale\{locale}" to the source path.

This leaves one warning that appears when the project is compiled. It complains that com.adobe.cairngorm.CairngormError uses ResourceBundle.getString(), "which has been deprecated". I'm inclined to let the folks at Adobe Consulting fix this one, as it's in the Cairngorm code.

12 Responses to “Updated: Chen Bekor’s ModifiedCairngormStore”

  1. Chen Bekor Says:

    Right on! this is super job.

  2. Fernando Ghisi Says:

    Thanks Douglas! This good example is now up to date.

  3. Christophe Herreman Says:

    Hi Douglas,

    in case you’re interested: I just added a new sample to Prana, based on your updated Cairngorm Store, that uses an application context to configure its business delegates and service locator.

    http://www.herrodius.com/blog/131

    regards,
    Christophe

    ps: an example for the event sequencing is on my todo list for the next release

  4. ron mori Says:

    Doug,
    Nicely done – it was a big help as I ramp up on Cairngorm.
    Thanks,
    Ron

  5. Cindy Says:

    hiya-
    I just downloaded this into Eclipse using the Flex plug-in and am getting Problem Occurred:
    Launching New_Configuration ()
    java.lang.NullPointerException

    I tried unzipping first then importing and then just importing as a Flex project, pointing to the zip file, but I can’t run the mxml either way

    thanks
    Cindy

  6. Maggie Says:

    Thanks so much for this – it often seems like an exercise in futility to find good examples of Flex 3/Cairngorm 2.2.1 apps – this is a big help for those who want to get up to speed – and is the first complex app that has imported and run successfully without any errors at all!

    I was able to find a CF version for this app, but it is buggy. That said, if anyone out there knows of any good Flex 3/Cairngorm 2.2.1/ColdFusion examples out there that work, please let me know!

  7. Vern Says:

    Love the example. Is this the place to ask questions regarding your update?

    I see a NewScreenEvent.as and NewScreenEvent is being called in the GeneralInformation component.

    But I don’t see where the NewScreenEvent is being handled. Should there be a NewScreenEvent entry in the ShopController.as file?

    Should there be a NewScreenCommand.as file?

    I hope I didn’t overlook this in your code, but I seem to be missing something.

  8. Douglas McCarroll Says:

    Vern,

    It looks like you’re correct. It looks as though Chen Bakor (who created this example – I just updated it to 2.2.1) didn’t implement the fuctionality that would be triggered by NewScreenEvent.

    If you figure out what it should do, and implement it in the example, please let us know. :)

    Douglas

  9. David Rader Says:

    Hi Doug,
    Just a FYI, there’s a bug in the locale due to the name of your locale directory (en_us). The issue is that the directory should be named “en_US” to correspond to the flex locale directory. My guess is that under Windows the case of “us” is not critical; however, under Linux a compiler error is thrown (unable to open {your-project-path}/locale/en_US).

    Simply rename the en_us directory located at {your-project-path}/locale/ to en_US, compile, and you should be all set.

    david

  10. Douglas McCarroll Says:

    Thanks, David. I’ve updated the folder’s name in the downloadable zip file.

  11. mallsop Says:

    For a windows build.bat compile example:

    @echo off
    echo Flex3 compile Main.mxml
    SET OPTS=-source-path=locale/{locale}
    C:\yourname\flex3\bin\mxmlc.exe %OPTS% src/Main.mxml
    pause

  12. Hemen Says:

    I am not sure if this was overlooked or if I am missing something. In the downloaded zip file ShopModelLocator implements ModelLocator interface. How ever as per the comment in com.adobe.cairngorm.model.ModelLocator.as, as per 2.1 ModelLocator is deprecated and replaced by

    com.adobe.cairngorm.model.IModelLocator

    In that case should not the code be changes as

    line # 37 import com.adobe.cairngorm.model.IModelLocator;

    and line # 47

    public class ShopModelLocator implements IModelLocator

Leave a Reply