I'll second this approach : 1. use as much as possible the Model Locator and bindings to avoid commands<>views dependencies, 2. when not sufficient or not elegant, use a viewhelper.
Benoit Hediard (which was using too much viewhelpers at the begining ;) ) -----Message d'origine----- De : flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] De la part de João Fernandes Envoyé : vendredi 17 février 2006 13:08 À : flexcoders@yahoogroups.com Objet : RE: [flexcoders] Cairngorm2 reusable commands 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: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Alberto Albericio Salvador Sent: sexta-feira, 17 de Fevereiro de 2006 11:45 To: flexcoders@yahoogroups.com 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 -- Alberto Albericio Salvador Aura S.A. Seguros Departamento Informática -- 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 <*> 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/