<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/stylesheets/rss.css" type="text/css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>OnRails.org: Cairngorm Generators</title>
    <link>http://onrails.org/articles/2007/02/21/cairngorm-generators</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Ruby On Rails and related matters.</description>
    <item>
      <title>Cairngorm Generators</title>
      <description>&lt;p&gt;I looked into &lt;a href="http://labs.adobe.com/wiki/index.php/Cairngorm"&gt;Cairngorm&lt;/a&gt; a while ago (version 0.95 I believe, pre-ModelLocator area) and didn&amp;#8217;t like the fact that you couldn&amp;#8217;t use Flex bindings at that time.  I recently gave it a second look I liked what I saw. Using Cairngorm is at first very verbose but it provides you with a clear way of organizing your code, which is very beneficial on larger projects. Cairngorm is well documented and there are several nice examples available. Also checkout &lt;a href="http://www.cairngormdocs.org/"&gt;http://www.cairngormdocs.org/&lt;/a&gt;. So yesterday introduced Cairgorm on two Flex projects I am working on.&lt;/p&gt;


	&lt;p&gt;The first project is a larger Flex 1.5 project (65 actionscript classes, 75 Data transfer object, &amp;gt;100 Mxml views) that I need to migrate to Flex 2.0. I though &amp;#8220;great time to start with Cairngorm&amp;#8221;. So the first step was to look at all the user gestures for all the screens and create a list of events, map these events to commands, create 3 delegates and services to handle all the remote calls.  On paper that was pretty fast to do, but I didn&amp;#8217;t want to create all the Cairngorm supporting class by hand. Handily I found the following generator that is a &lt;span class="caps"&gt;PHP&lt;/span&gt; application:&lt;/p&gt;


&lt;block&gt;
&lt;a href="http://www.ericfeminella.com/blog/2007/01/04/introducing-cairngen/"&gt;Cairngen&lt;/a&gt;
&lt;/block&gt;

	&lt;p&gt;&lt;br/&gt;
It targets currently only Cairngorm 2.0 and not the newer Cairngorm 2.1. So after generate the supporting classes I had to manually do some changes. But thanks for this tool.&lt;/p&gt;


	&lt;p&gt;The second project is a smaller Flex application backed by a Ruby on Rails server. And I found the following Ruby on Rails Cairngorm generators at http://code.google.com/p/cairngorm-rails-generator/&lt;/p&gt;


	&lt;p&gt;Simply copy the generators to your &amp;#8221;/vendor/generators&amp;#8221; folder, the generators folder will then contain the following generators:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;cairngorm
command
delegate
event
vo
worbservice&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;Note there are several places in Rails you can set generators, but that did the trick for me. The I created  a &amp;#8220;src&amp;#8221; folder in my Rails root folder and issues the following commands:&lt;/p&gt;


Then you can use these different generator commands to build the structure you require, the events, commands, delegates and more.
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;   ./script/generate cairngorm org/onrails/myspyder   
   ./script/generate delegate  org/onrails/myspyder server
   ./script/generate command   org/onrails/myspyder show_page_watch server
   ./script/generate event     org/onrails/myspyder show_page_watch &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;I issued the generate script for each of the commands that application needs to support. The main controller now looks as follows (still very early in the development phase)&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;package org.onrails.myspyder.control
{
    import com.adobe.cairngorm.control.FrontController;
    import com.adobe.cairngorm.control.CairngormEventDispatcher;
    import org.onrails.myspyder.control.*;
    import org.onrails.myspyder.command.*;

    public class MySpyderController extends FrontController
    {
        public function MySpyderController()
        {
            initialiseCommands();
        }

        public function initialiseCommands() : void
        {
            // Application Tabs
            addCommand( ShowAccountEvent.EVENT_SHOW_ACCOUNT, ShowAccountCommand );
            addCommand( ShowPagesEvent.EVENT_SHOW_PAGES, ShowPagesCommand );
            addCommand( ShowSettingsEvent.EVENT_SHOW_SETTINGS, ShowSettingsCommand );            

            // Page List
            addCommand( ReloadPagesEvent.EVENT_RELOAD_PAGES, ReloadPagesCommand );
            addCommand( AddPageEvent.EVENT_ADD_PAGE, AddPageCommand );
            addCommand( ReloadPageEvent.EVENT_RELOAD_PAGE, ReloadPageCommand );
            addCommand( RemovePageEvent.EVENT_REMOVE_PAGE, RemovePageCommand );
            addCommand( SavePageEvent.EVENT_SAVE_PAGE, SavePageCommand );

            // Page Details
            addCommand( ShowPageWatchEvent.EVENT_SHOW_PAGE_WATCH, ShowPageWatchCommand );
            addCommand( ShowPageWatchResultEvent.EVENT_SHOW_PAGE_WATCH_RESULT, ShowPageWatchResultCommand );

            // Html Section
            addCommand( ShowOriginalPageEvent.EVENT_SHOW_ORIGINAL_PAGE, ShowOriginalPageCommand );
            addCommand( ShowPageSectionEvent.EVENT_SHOW_PAGE_SECTION, ShowPageSectionCommand );
            addCommand( SelectPageSectionEvent.EVENT_SELECT_PAGE_SECTION, SelectPageSectionCommand );

        }    

    }

}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;Let me know your experience with Flex and Cairngorm.&lt;/p&gt;</description>
      <pubDate>Wed, 21 Feb 2007 19:40:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:22086a10-e835-42d7-8013-f23f02e15972</guid>
      <author>Daniel Wanja</author>
      <link>http://onrails.org/articles/2007/02/21/cairngorm-generators</link>
      <category>Flex</category>
      <category>Ruby On Rails</category>
    </item>
    <item>
      <title>"Cairngorm Generators" by forest</title>
      <description>&lt;p&gt;ilva,&lt;/p&gt;


	&lt;p&gt;The generators are great. I have been very happy with them. They save lots of time writing boiler point code.&lt;/p&gt;


	&lt;p&gt;daniel,&lt;/p&gt;


	&lt;p&gt;Are you using cairngorm and weborb with your flex/rails application? It seems the rails controllers are not used at all, is this correct?&lt;/p&gt;


	&lt;p&gt;Thanks,
forest&lt;/p&gt;</description>
      <pubDate>Fri, 23 Mar 2007 15:43:10 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:eacb0707-7b45-4592-b33d-aba3b8bdfe6e</guid>
      <link>http://onrails.org/articles/2007/02/21/cairngorm-generators#comment-303</link>
    </item>
    <item>
      <title>"Cairngorm Generators" by ilya</title>
      <description>&lt;p&gt;doh,&lt;/p&gt;


	&lt;p&gt;i saw you actually write about it.&lt;/p&gt;


	&lt;p&gt;how do you think we can improve it?&lt;/p&gt;</description>
      <pubDate>Thu, 01 Mar 2007 21:59:15 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:89abc777-13f2-4a61-8921-a5d54752b932</guid>
      <link>http://onrails.org/articles/2007/02/21/cairngorm-generators#comment-277</link>
    </item>
    <item>
      <title>"Cairngorm Generators" by ilya</title>
      <description>&lt;p&gt;Hi Daniel,&lt;/p&gt;


	&lt;p&gt;i whipped up a rails generator for cairngorm during my last x-mass holliday in a few evenings.&lt;/p&gt;


	&lt;p&gt;feel free to take a look and comment
&lt;a href="http://code.google.com/p/cairngorm-rails-generator/"&gt;http://code.google.com/p/cairngorm-rails-generator/&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;i still didn&amp;#8217;t get around taking it a step further, but maybe you like the idea&lt;/p&gt;</description>
      <pubDate>Thu, 01 Mar 2007 21:57:47 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:e04911cc-fb16-4e9f-8052-7ae763ae8ffa</guid>
      <link>http://onrails.org/articles/2007/02/21/cairngorm-generators#comment-276</link>
    </item>
    <item>
      <title>"Cairngorm Generators" by Daniel Wanja</title>
      <description>&lt;p&gt;Thanks, that&amp;#8217;s a good trick. Also the Cairngorm Rails generator does not overwrite files, so you won&amp;#8217;t loose your changes when you add code to the generated files.&lt;/p&gt;</description>
      <pubDate>Thu, 22 Feb 2007 13:46:20 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:877fd996-9dc7-415c-8e4d-c191e51e2c24</guid>
      <link>http://onrails.org/articles/2007/02/21/cairngorm-generators#comment-255</link>
    </item>
    <item>
      <title>"Cairngorm Generators" by Alex MacCaw</title>
      <description>&lt;p&gt;Change all instances of &amp;#8216;src&amp;#8217; to &amp;#8217;..&amp;#8217;, then put the rails app in your Flex Builder (or whatever you use dir). This then generates all the code, without you having to copy anything over&amp;#8230;.&lt;/p&gt;</description>
      <pubDate>Thu, 22 Feb 2007 10:13:09 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:6e50beb5-9dc0-4ab5-8183-8f1e399d9fbc</guid>
      <link>http://onrails.org/articles/2007/02/21/cairngorm-generators#comment-254</link>
    </item>
  </channel>
</rss>
