Hi Joao,
I dont agree at all hehe For me, it is ok that commands know about views
(or whatever dispatches the event that started that command)
Imagine this situation:
You have a screen where 2 components ask for the weather on a zip code,
so I can see weather on 2 locations at the same time. What I say is:
I need both components to dispatch the same event("getWeather") but with
different parameter (zip code) and get the results back to them using
the same command. I dont want to use a single application pool to store
my results.
Alberto Albericio Salvador
Aura S.A. Seguros
Departamento Informática
João Fernandes escribió:
> Alberto,
>
> In my opinion commands shouldn't be aware of the views. It's not what
> cairngorm is made for. Dispatch your event and set the result to some
> variable in your ModelLocator. Then if foobar1 and foobar2 need that info,
> use bindings and bind them to that variable ... Do you need to transform that
> information in a different way for each one? Fine, use the Foobar1ViewHelper
> and Foobar2ViewHelper to do it.
>
> Example:
>
> Foobar1.mxml
> <mx:Script>
> <![CDATA[
> Import your.model.locator.path.ModelLocator;
> [Bindable]
> public var model:ModelLocator =
> ModelLocator.getInstance();
> ]]>
> </mx:Script>
> <mx:Combobox dataProvider="{Foobar1ViewHelper.formatMyModel(model.myVar)}"/>
>
> Foobar2.mxml
>
> <mx:Combobox
> dataProvider="{Foobar2ViewHelper.formatDifferentlyMyModel(model.myVar)}"/>
>
>
> João Fernandes
> Sistemas de Informação
>
> Programador Informático
> Cofina media
>
> Avenida João Crisóstomo, Nº 72 . 1069-043 Lisboa PORTUGAL
> Tel (+351) 213 185 200 . Fax (+351) 213 540 370
> [EMAIL PROTECTED]
>
>
> -----Original Message-----
> From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of
> Alberto Albericio Salvador
> Sent: sexta-feira, 17 de Fevereiro de 2006 11:45
> To: [email protected]
> Subject: [flexcoders] Cairngorm2 reusable commands
>
> Hi all,
>
> In Cairngorm commands, I always define statically where I want "some
> results" to be sent (normally a custom function in component that
> extends ViewHelper). This updates my view and works fine. But...
>
> How can I make that command Class to send "some results" to whatever
> asked for them (who dispatched the event that threw that command)?
>
> Eg:
>
> foobar1.mxml and foobar2.mxml
> ..
> public function setResults(someResults):void {
> //update my controls
> }
>
> public function getResults():void {
> dispatchEvent("askForResults");
> }
> ....
>
> foobar1 and foobar2 dispatch the same event and the command needs to
> know where to send back the results and run setResults on the
> corresponding caller. How can I achieve this?
>
> Thanks in advance
>
>
>
--
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
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/