In 1, the peeps I've worked with have done the same thing.  We do not use
ViewHelpers.  We've basically built our own version of ViewLocator.  The
Cairngorm 1 version took a ViewHelper ID usually whereas we just pass in the
View's id name with a reference.  So:

<?xml version="1.0" encoding="utf-8"?>
<mx:Panel
    creationComplete="onMyPanelCreationComplete()"
    unload="onUnloaded()"
     xmlns:mx="http://www.macromedia.com/2003/mxml">

<mx:Script>
<![CDATA[

    import ViewLocatorX;

    function onMyPanelCreationComplete()
    {
        ViewLocatorX.registerComponentByID(this.id, this);
    }

    function onUnloaded()
    {
        ViewLocatorX.unregisterComponentByID(this.id, this);
    }

</mx:Panel>

So, when she's loaded up, the ViewLocator has a reference to it.  You can
pass in a string name to access it.  Pretty flexible using a string, but
dangerous unless you put those "globally accessible views" names in a
constant class somewhere.  Example:

class ViewNameConstants
{
    public static var LOGIN_PANEL:String = "loginPanel";
}

That way, when you do this:

<view:LoginPanel id="loginPanel" xmlns:view="*" />

As long as you don't have deferred instantiation on, you can do:

var loginPanel = ViewLocator.getComponentByID (
ViewNameConstants.LOGIN_PANEL );
loginPanel.doLogin();

Cairngorm purists would be strong proponents of binding the LoginPanel to a
state variable, and modifying that state variable in a Command.  The
LoginPanel could then have one of its bindings fire, and thus call that
method.

However, until recently, we didn't have the ability to support Command
callbacks.  As such we had a log of views that needed to know when their
data was ready.  For display it's pretty easy; you just bind your DataGrid
to an array; poof, your done.  But for more advanced scenarios when you need
to act upon that data, without knowledge of when a command is done (or some
other dataservice specific event), you start ending up with a plethora of
state variables.  To me, that's an f'ing nightmare.  Flex is already event
based, and it's built into the player in Flash Player 9, so why not use
events?

Cairngorm originally didn't support callbacks, but it's trivial to add.  As
such, I still have instances where I use a ViewLocator (albeit 3 if I
remember correctly within a huge code base) where I need to call a method on
another view.  I don't like doing it, but still view it as a valid solution.

I akin it to Singleton vs. Memento.  You see many many cases of Singleton
being used, and it generally accepted practice to utilize Singletons.  Not
many people use, nor talk about, Memento.  It's still a valid pattern to
solve problems though.  ViewLocator, to me, just has a hack feeling to it,
but I'd be hard pressed to live without it.

Cairngorm 2?  Basically same thing.  You're ViewLocator would work about the
same in both instances:

package
{
    public class ViewLocator
    {

        protected var components_hash:Object;

        public function registerComponentByID ( p_id:String,
p_ref:UIComponent):void
        {
            components_hash[p_id] = p_ref;
        }
    }
}

Pseudo code, but you get the point.



----- Original Message -----
From: "Jonathan Miranda" <[EMAIL PROTECTED]>
To: <flexcoders@yahoogroups.com>
Sent: Wednesday, April 26, 2006 5:51 PM
Subject: Re: [flexcoders] PLEASE: Could someone at Adobe/Macromedia do a
Carnigorm Video Intro.


Let's be difficult....both! :)

On 4/26/06, JesterXL <[EMAIL PROTECTED]> wrote:
> In Cairngorm 1 or 2?
>
> ----- Original Message -----
> From: "Jonathan Miranda" <[EMAIL PROTECTED]>
> To: <flexcoders@yahoogroups.com>
> Sent: Wednesday, April 26, 2006 5:35 PM
> Subject: Re: [flexcoders] PLEASE: Could someone at Adobe/Macromedia do a
> Carnigorm Video Intro.
>
>
> Got any examples of this Jester?
>
> On 4/26/06, JesterXL <[EMAIL PROTECTED]> wrote:
> > If you're an OOP, Cairngorm purist, sure.  However, for those of use
> > under
> > extreme deadlines who have no problem tossing lofty ideals out the
> > window,
> > ViewLocator is a life saver.  If there is a need to have some view tell
> > another view not within the direct DisplayList to do something, it's a
> > nice
> > to have.  To be honest, I feel dirty everytime I use it though.
> >
> > ----- Original Message -----
> > From: <[EMAIL PROTECTED]>
> > To: <flexcoders@yahoogroups.com>
> > Sent: Wednesday, April 26, 2006 3:19 PM
> > Subject: Re: [flexcoders] PLEASE: Could someone at Adobe/Macromedia do a
> > Carnigorm Video Intro.
> >
> >
> > I'll send you a copy.
> >
> > On another note, I was looking at the ViewLocator/ViewHelper code and I
> > found myself wondering how to implement it.  It's not that the theory
> > isn't
> > sound, I'm sure it is -  just try to find some simple working examples.
> > Anyone out there have some simple Cairngorm2 ViewLocator examples?
> > Steve
> > Webster had mentioned to me that the ModelLocator can handle all the
> > work
> > that the ViewLocator/ViewHelper is intended to do, so perhaps they are
> > not
> > necessary. Thoughts?
> >
> >
> >
> >
> >
> >
> >              "Darren Houle"                    To:
> > flexcoders@yahoogroups.com
> >              <[EMAIL PROTECTED]>              cc:
> >              Sent by:                          Subject:  Re:
> > [flexcoders]
> > PLEASE: Could someone at Adobe/Macromedia do a Carnigorm
> >              flexcoders@yahoogroups.com          Video Intro.
> >              04/26/2006 11:10 AM
> >              Please respond to
> >              flexcoders
> >
> >
> >
> >
> >
> >
> > Hey Michael
> >
> > Any chance I could get that from you too?  I've found the available Cg2
> > examples out there somewhat lacking... the 6 part article talks about
> > and
> > uses Cg.99, but I have F2B2 installed so I want to learn Cg2.  The Cg2
> > CairngormLogin example has little documentation (not that it really does
> > much anyway)... and there's a PhonesCairngorm2 example, but it's
> > complex,
> > uses Data Services, requires CF code, so... what I'd love to get my
> > hands
> > on
> > would be a simple Cg2 example, one that has a couple simple RPC services
> > to
> >
> > something like a public blog feed or a local XML data file, a couple
> > VOs,
> > a
> >
> > couple commands, a couple views, a couple controls.  Nothing overly
> > complicated and something with some healthy documentation (even inline
> > comments would be fine.)  Your example might not meet all those
> > criteria,
> > but that's totally okay, I'll take anything :-)
> >
> > Thanks!
> > Darren
> >
> >
> >
> > >From: [EMAIL PROTECTED]
> > >Reply-To: flexcoders@yahoogroups.com
> > >To: flexcoders@yahoogroups.com
> > >Subject: Re: [flexcoders] PLEASE: Could someone at Adobe/Macromedia do
> > >a
> > >Carnigorm Video Intro.
> > >Date: Wed, 26 Apr 2006 09:51:56 -0400
> > >
> > >  I have a very (very) simple sample app that I use to illustrate how
> > > to
> > >get
> > >the ball rolling with Cairngorm2  that I can send to you.  It includes
> > >documentation on how to add your own dispatchEvent in step-by-step
> > >instructions.  I'm not knocking the Cairngorm2 'Login' example, but I
> > think
> > >that a 'hold-your-hand' example is helpful for those getting familiar
> > >with
> > >patterns.
> > >
> > >
> > >
> > >---------------------------------------------------------------------------
> >
> > >This e-mail message (including attachments, if any) is intended for the
> > use
> > >of the individual or entity to which it is addressed and may contain
> > >information that is privileged, proprietary , confidential and exempt
> > >from
> > >disclosure.  If you are not the intended recipient, you are notified
> > >that
> > >any dissemination, distribution or copying of this communication is
> > >strictly prohibited.  If you have received this communication in error,
> > >please notify the sender and erase this e-mail message immediately.
> > >---------------------------------------------------------------------------
> >
> > >
> > >
> > >
> > >
> > >--
> > >Flexcoders Mailing List
> > >FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > >Search Archives:
> > >http://www.mail-archive.com/flexcoders%40yahoogroups.com
> > >Yahoo! Groups Links
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> >
> >
> >
> >
> > --
> > Flexcoders Mailing List
> > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > Search Archives:
> > http://www.mail-archive.com/flexcoders%40yahoogroups.com
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > ---------------------------------------------------------------------------
> > This e-mail message (including attachments, if any) is intended for the
> > use
> > of the individual or entity to which it is addressed and may contain
> > information that is privileged, proprietary , confidential and exempt
> > from
> > disclosure.  If you are not the intended recipient, you are notified
> > that
> > any dissemination, distribution or copying of this communication is
> > strictly prohibited.  If you have received this communication in error,
> > please notify the sender and erase this e-mail message immediately.
> > ---------------------------------------------------------------------------
> >
> >
> >
> >
> > --
> > Flexcoders Mailing List
> > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > Search Archives:
> > http://www.mail-archive.com/flexcoders%40yahoogroups.com
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
> > --
> > Flexcoders Mailing List
> > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > Search Archives:
> > http://www.mail-archive.com/flexcoders%40yahoogroups.com
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
>
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
> Yahoo! Groups Links
>
>
>
>
>
>
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
> Yahoo! Groups Links
>
>
>
>
>
>
>
>


--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links







--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




YAHOO! GROUPS LINKS




Reply via email to