All in One – Cairngorm Store Example (ColdFusion, AMFPHP, AMFPHP 1.9, and WebServices)

Posted on December 19, 2006 | 27 comments

I have updated the Cairngorm Store multiple backend example. Along with the updated source code I have deploy a live running example. The 4 backends it supports now is ColdFusion Remoting AMF3, AMFPHP AMF0 using the RemoteObjectAMF0 class, AMFPHP 1.9 AMF3, and ColdFusion WebServices.

See it live here!

Get the source here!

To change the backend of the Cairngorm Store example just select the backend you want from ComboBox and then click on the Refresh Data button. I had to do write some exception code to convert the returned XML data into the ArrayCollection to conform all the backend but besides that it was really easy to integrate all of them into the Services.mxml.

PS: I just installed a new license on the ColdFusion server with a new Apache web server configuration so let me know if there are any issues.

  • Tib

    How can I take a peek into the frontend sources? “View Source” within the live app doesn’t work. ..or is it the demo Cairngorm Store without changes?


  • Renaun Erickson

    Sorry I had the wrong source files in the zip folder. The source link has the updated source files now.

  • Ashish

    Hello..trying to run this and getting few errors when I imported the code into a new project.

    1) Could not resolve to a component implementation…in Services.mxml..CairngormStoreMultipleBackend/com/adobe/cairngorm/samples/store/business (line 40)

    2) Type was not found or was not a compile-time constant: DataService…in
    (line 92)

    First, I created a new project and imported your files into it. The, I downloaded Cairngorm 2.1 files..and imported that into the same project (overwriting existing files)

    I believe this is for Cairngorm 2.1..correct? Also, trying to understand what I need to do on the CF side..any help would be appreciated.

    Thank you,

  • Wade Arnold

    Thanks so much Renaun!

  • Mark McCray

    Hey Renaun,
    I’m getting an error in my Services.mxml saying it can’t resolve to a component implementation.

    I have:

    and it’s complaining about that line.
    I just downloaded the source files today and wanted to try them out. Any help would be appreciated.

  • Pingback: bjornblog talks about .. » Getting started with Cairngorm

  • Pete Mackie

    I attempted to build the Cairngorm Store with Flex Builder 2.0.1 and receive the following messages.

    1) Could not resolve to a component implementation.

    2) 1017: The definition of base class FrontController was not found.

    3) 1017: The definition of base class CairngormEvent was not found.

    4) 1020: Method marked override mus override another method.

    5) 1017: The definition of base class CairngormEvent was not found.

    6) 1020: Method marked override mus override another method.

    7) 1045: Interface ModelLocator was not found.

    8) 1045: Interface IValueObject was not found.

    Any help you can provide would be appreciated.


  • diamondTearz

    This is really great! It bridges the gap between a beautiful solution in theory and the implementation.


  • Juan Carlos M.

    I have a question…
    Is there a problem of concurrency in RemoteObjectAMF0?
    This is my test:

    Server Side:
    a) I have a generic pageable search service in Java (I’am using RemoteObjectAMF0 and openamf). It returns a list (a page of results) with value objects. Value Objects’ Class is determined by service params.

    Client Side:
    b) I have two different screens that use that search service. Screen 1 expects objects of Type A and Screen 2 expects objects of Type B. Both screens are at the same time on screen
    a kind of MDI…I hope ;)
    I am using cairngorm 2.1. (a command is created per event )

    c) Some searches with Screen 1 : works fine.

    d) Some searches with Screen 2: works fine.

    e) “Parallel” search with screen 1 and screen 2:
    Firs request of screen 1 and second request (almost parallel) of screen 2

    f)Server logs are ok for both requests:
    First Response : [results for screen 2, only 777 objects]
    2007-01-22 01:07:57,859 estimatedTotalResultsCount:777
    Total Pages:4 Pagesize:200
    startIndex: 0 lastIndex:199}]

    Second Response : [results for screen 1, 131427 expected]
    2007-01-22 01:07:57,890 estimatedTotalResultsCount:131427
    Total Pages:658 Pagesize:200
    startIndex: 0 lastIndex:199}]

    g) Client side Brokes. It seems that “something” puts response of service 1 in service 2.
    [postprocessing of object (ordering) fails, caused by "mixes" of responses ]

    This is the code of my Command:

    private var recievedEvent : SearchEvent;

    public function execute( event : CairngormEvent ): void {
    var delegate : SearchDelegate = new SearchDelegate( this );
    recievedEvent = SearchEvent( event );;

    public function result( event : Object ) : void {
    var search:Search = event.result as Search;

    h) Its a little weird problem… Search works fine individually.. but in “parallel” brokes.
    - Could be a concurrency problem in service? ( )
    - Could be a problem in cairngorm?
    - Could be a problem in my commands?

    Thanks for your time and your help.

  • Amjad

    What is wrong here

    Error #2044: Unhandled NetStatusEvent:. level=error, code=NetConnection.Call.BadVersion
    at com.renaun.rpc::RemoteObjectAMF0/
    at com.adobe.cairngorm.control::FrontController/com.adobe.cairngorm.control:FrontController::executeCommand()
    at com.adobe.cairngorm.control::CairngormEventDispatcher/dispatchEvent()
    at CairngormStoreWebMain/::onCreationComplete()
    at CairngormStoreWebMain/___Application1_creationComplete()
    at mx.core::UIComponent/dispatchEvent()
    at mx.core::UIComponent/set initialized()
    at mx.managers::LayoutManager/::doPhasedInstantiation()
    at Function/
    at mx.core::UIComponent/::callLaterDispatcher2()
    at mx.core::UIComponent/::callLaterDispatcher()

  • Renaun Erickson

    NetConnection.Call.BadVersion usually means the gateway is not working, configured wrong, or its spitting out errors. Which backend is this happening on ColdFusion or AMFPHP?

  • Trevor

    has anyone found a solution to the “Could not resolve to a component implementation…in Services.mxml” error? I’m struggling w/ this as well.

    if you have a solution could you post it? thanks!

  • Lucas

    Is it me, or when running the example from this site the amfphp1.9 deliverer a message “cannot show products” or something similiar?

    why is that?

  • Renaun Erickson

    I do see the error, I look into it. I made some server configuration changes a while back.

  • Renaun Erickson

    The error is fixed and the examples are working again. Sorry about that.

  • Brian Lewis

    Change the XML namespace to point to the RemoteObjectAMF0 package (you will need to download it if you don’t have it).

    on line 40…

    change this:

    to this:

    - Brian

  • Renaun Erickson

    I usually create the SWC’s with manifest’s and namespaces. But if you are using the source RemoteObjectAMF0 class then you’ll need to use the package name in the namespace, like you have mentioned.

  • philipp

    i’m trying to get the store running on my local machine (using amfphp 1.9). so far – so good.
    but i always get this error message telling me that the cast went wrong.

    TypeError: Error #1034: Typumwandlung fehlgeschlagen: []@eee9791 kann nicht in mx.collections.ICollectionView umgewandelt werden.

    (unfortunately it’s in german but i think one can get the meaning behind it …)

    maybe you can hint me in the right direction …


  • Renaun Erickson

    I need to see the code where in GetProductsCommand that you are trying to cast….Something must be slightly different in on the front end or the backend to cause a casting error.

  • philipp

    i didn’t change any code …
    so line 74 in com\adobe\cairngorm\samples\store\command\ looks like it always did:

    var products : ICollectionView = ICollectionView( event.result );


  • J Buda


    I have trying to load in an xml file and display the results and populating a selectedItem with Cairngorm, but i kept getting errors.

    Using your ArrayCollection for xml i have managed to get it working!

    Many Thanks

  • J Buda

    Hi Again…..

    Im a bit confused with the model.selectedItem..

    On the store, when you change between Graphical Product List and Textual Product List…..why does the updateSelectedProduct method change?

    On the TextualProductList.mxml, the method CairngormEventDispatcher is used, and doesnt work!
    However, on the Graphical Product List an normal dispatchEvent method is used and seems to work fine.

    I have been following the code in the store to create an application of my own, but im slightly confused to the different methods that have been used to dispatch the update selected product


  • Renaun Erickson

    This code was taken from Adobe Consulting example. I personally feel the code is a little confusing to follow. But you can still gleam some valuable code bits from it. So in the end I wouldn’t follow it to closely and there might be errors.

    All I did with the multiple backend exercise was to show that you can take a Cairngorm application and quite easily change out the backend.

  • J Buda

    Hi again…

    Im trying to create an ArrayCollection after returning a xml from a webservice.

    My xml returns an object that has a nested children within a node. ie.

    My question is this….i can i create the ArrayCollection using the xmlFactory? Im having problems with generating the replicating the ArrayCollection with the sample xml above?


  • J Buda

    oops……the sample xml isnt showing!

  • cultfigure

    I too was having the same problem Philipp was having when I tried to migrate from AMFPHP1.2 to 1.9beta2 where the result would die upon casting the event.result to an ICollectionView…

    I (eventually) found the answer here, quoting:

    There was one line of ActionScript in the result method that I didn’t understand:

    var products : ICollectionView = ICollectionView( event.result );

    This line creates a product variable of ICollectionView, and calls the ICollectionView constructor with the ‘event.result’ as an argument. Unfortunately, ICollectionView is an interface and does not appear to have a constructor. This line was throwing errors.

    After some digging I found that an ArrayCollection inherits the ICollectionView methods through the ListCollectionView class. All code written against the ICollectionView interface should also work against an ArrayCollection. I replaced the ICollectionView line above with these two:

    var products : ArrayCollection = new ArrayCollection ();
    products.source = event.result as Array;

    And bingo, everything started working.

  • Adam

    It appears the source for this article doesnt include the AMF3 option in the drop down but the online app does. Is it possible to post the latest code for this.

  • dl

    could anyone post an example how to pass VO’s from Flex using cairngorm to amfphp and from amfphp back to flex.
    I already googled and try to simply pass an vo without cair but even that was not working.
    Well, a complete as simple as possible example would make things more clear and more joy.

    Yours Faithfully

  • Pingback: Getting started with Cairngorm | | Bjørn Børresen - freelance web developer