Updated: Chen Bekor’s ModifiedCairngormStore
February 21st, 2008
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.
February 22nd, 2008 at 3:16 am
Right on! this is super job.
February 22nd, 2008 at 10:00 am
Thanks Douglas! This good example is now up to date.
February 24th, 2008 at 4:41 pm
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
March 17th, 2008 at 7:56 pm
Doug,
Nicely done – it was a big help as I ramp up on Cairngorm.
Thanks,
Ron
June 26th, 2008 at 3:33 pm
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
January 9th, 2009 at 4:52 pm
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!
February 4th, 2009 at 1:24 pm
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.
February 5th, 2009 at 12:16 pm
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
June 5th, 2009 at 11:42 am
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
June 5th, 2009 at 10:23 pm
Thanks, David. I’ve updated the folder’s name in the downloadable zip file.
June 26th, 2009 at 2:49 pm
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
July 30th, 2009 at 5:45 pm
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
May 25th, 2010 at 9:03 pm
The CairngormError warning in Flex 3 is still present in Flex 4 but now is accompanied by a build error as well. Also, a Flex 3 built Cairngorm 2.2.1 will now have runtime failures when used with a Flex 4 compiled app. This is a problem with Cairngorm source, not your updates to the CairngormStore, but thought I’d ask whether you or others have attempted to update Cairngorm 2.2.1 and CairngormStore to work with Flex 4.
Build errors with Flex 4, fyi, are:
Call to a possibly undefined method getResourceBundle through a reference with static type Class.
Call to a possibly undefined method getString through a reference with static type mx.resources:ResourceBundle.
Both occur on the first line of the formatMessage function.
The runtime errors you’d get using a Flex 3 built Cairngorm binary with a Flex 4 app are similar to the above and I presume a result of methods like ResourceBundle.getString() being removed in Flex 4.