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?

    Tib

  • http://www.renaun.com 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 IServiceLocator.as..CairngormStoreMultipleBackend/com/adobe/cairngorm/business
    (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,
    ashish

  • http://www.t8design.com 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.
    Thanks!
    markymark

  • 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.
    Services.mxml

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

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

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

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

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

    7) 1045: Interface ModelLocator was not found.
    ShopModelLocator.as

    8) 1045: Interface IValueObject was not found.
    ProductVO.as

    Any help you can provide would be appreciated.

    Pete

  • http://diamondtearz.org/blog diamondTearz

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

    M

  • http://flex2colombia.wordpress.com/ Juan Carlos M.

    Hi.
    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 );
    delegate.search(recievedEvent.searchable.getSearchParams());
    }

    public function result( event : Object ) : void {
    var search:Search = event.result as Search;
    recievedEvent.searchable.setSearch(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/http://www.adobe.com/2006/actionscript/flash/proxy::callProperty()
    at com.adobe.cairngorm.samples.store.business::ProductDelegate/getProducts()
    at com.adobe.cairngorm.samples.store.command::GetProductsCommand/execute()
    at com.adobe.cairngorm.control::FrontController/com.adobe.cairngorm.control:FrontController::executeCommand()
    at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at com.adobe.cairngorm.control::CairngormEventDispatcher/dispatchEvent()
    at CairngormStoreWebMain/::onCreationComplete()
    at CairngormStoreWebMain/___Application1_creationComplete()
    at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at mx.core::UIComponent/dispatchEvent()
    at mx.core::UIComponent/set initialized()
    at mx.managers::LayoutManager/::doPhasedInstantiation()
    at Function/http://adobe.com/AS3/2006/builtin::apply()
    at mx.core::UIComponent/::callLaterDispatcher2()
    at mx.core::UIComponent/::callLaterDispatcher()

  • http://www.renaun.com 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

    Hei.
    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?
    :S

  • http://www.renaun.com Renaun Erickson

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

  • http://www.renaun.com Renaun Erickson

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

  • Brian Lewis

    Trevor:
    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:
    xmlns:renaun=”http://renaun.com/flex/rpc”

    to this:
    xmlns:renaun=”com.renaun.rpc.*”

    - Brian

  • http://www.renaun.com 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

    hi,
    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.
    at com.adobe.cairngorm.samples.store.command::GetProductsCommand/result()[C:\DEVELOP\cairngormwebstore\com\adobe\cairngorm\samples\store\command\GetProductsCommand.as:74]

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

    maybe you can hint me in the right direction …

    thanks,
    phil

  • http://www.renaun.com 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

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

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

    phil

  • http://www.jbuda.co.uk J Buda

    Fantastic!!

    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

  • http://www.jbuda.co.uk 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

    Thanks

  • http://www.renaun.com 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.

  • http://www.jbuda.co.uk 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?

    Thanks

  • http://www.jbuda.co.uk 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.
    Thanks

  • dl

    Hello,
    could anyone post an example how to pass VO’s from Flex using cairngorm to amfphp and from amfphp back to flex.
    *PLEASE*
    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
    dl

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