Comments on: Cairngorm Secret Tip #3: Responders for View Notifications http://www.gridlinked.info/cairngorm-secret-tip-3-responders-for-view-notifications/ Patterns with Flex, RUX, and software Sun, 29 Aug 2010 13:46:08 +0000 http://wordpress.org/?v=abc hourly 1 By: thomasbhttp://www.gridlinked.info/cairngorm-secret-tip-3-responders-for-view-notifications/#comment-217 thomasb Mon, 01 Mar 2010 15:45:03 +0000 http://www.gridlinked.info/?p=287#comment-217 Included in the open source code for CGX (Cairngorm Extensions) are the 2.2.1 adobe.cairngorm.* packages from the original framework. This inclusion is for developer convenience only! By including the Adobe base/parent code, developers are required only build/include the CGX swc into their applications. Of course you can delete the CGX com.adobe.cairngorm.* packages and use a separate SWC if desired. Please note also that the lastest Cairngorm 3 Beta has NOT been tested with the CGX extensions.UPDATE: the <a href="http://code.google.com/p/flexcairngorm/source/browse/#svn/trunk/code " rel="nofollow">CGX Framework</a> source code has been updated with FlashBuilder 4 project settings. Included in the open source code for CGX (Cairngorm Extensions) are the 2.2.1 adobe.cairngorm.* packages from the original framework. This inclusion is for developer convenience only! By including the Adobe base/parent code, developers are required only build/include the CGX swc into their applications. Of course you can delete the CGX com.adobe.cairngorm.* packages and use a separate SWC if desired. Please note also that the lastest Cairngorm 3 Beta has NOT been tested with the CGX extensions.

UPDATE: the CGX Framework source code has been updated with FlashBuilder 4 project settings.

]]>
By: ricardohttp://www.gridlinked.info/cairngorm-secret-tip-3-responders-for-view-notifications/#comment-216 ricardo Mon, 01 Mar 2010 08:43:34 +0000 http://www.gridlinked.info/?p=287#comment-216 The last version of is 2.2.1 these extensions were included, I must place the extension + frk orginal or not?? The last version of is 2.2.1 these extensions were included, I must place the extension + frk orginal or not??

]]>
By: thomasbhttp://www.gridlinked.info/cairngorm-secret-tip-3-responders-for-view-notifications/#comment-203 thomasb Wed, 24 Feb 2010 21:54:14 +0000 http://www.gridlinked.info/?p=287#comment-203 Matt, You have asked a great question that really needs to be answered in a new blog: " Flex View Coupling & Events (Best Practices)"... stay tuned for a full blog article with diagrams. Meanwhile, remember the following: 1) Business events typically are dispatched directly to the biz layer. Data changes trigger their own event notifications so views update as a result of data changes. 2) Non-business events typically bubble to the immediate parent. 3) Hidden events are also the "magic" that triggers databinding notifications to attached listeners. Parents can mediate activity between children views, or sibling/peer views can use databinding notations to directly coupling to properties of each other. View coupling is something most people get complete wrong. Black-box couplings are signs of great developers. Matt,
You have asked a great question that really needs to be answered in a new blog: ” Flex View Coupling & Events (Best Practices)”… stay tuned for a full blog article with diagrams.
Meanwhile, remember the following:
1) Business events typically are dispatched directly to the biz layer. Data changes trigger their own event notifications so views update as a result of data changes.
2) Non-business events typically bubble to the immediate parent.
3) Hidden events are also the “magic” that triggers databinding notifications to attached listeners.
Parents can mediate activity between children views, or sibling/peer views can use databinding notations to directly coupling to properties of each other.
View coupling is something most people get complete wrong. Black-box couplings are signs of great developers.

]]>
By: thomasbhttp://www.gridlinked.info/cairngorm-secret-tip-3-responders-for-view-notifications/#comment-202 thomasb Wed, 24 Feb 2010 21:46:29 +0000 http://www.gridlinked.info/?p=287#comment-202 Oops. That is a typo... ApplicationInitializeEvent() is supposed to be the constructor public function LoadUserDetails() { ... }. I will fix this is the code sample thanks.ThomasB Oops.
That is a typo… ApplicationInitializeEvent() is supposed to be the constructor public function LoadUserDetails() { … }.
I will fix this is the code sample thanks.

ThomasB

]]>
By: thomasbhttp://www.gridlinked.info/cairngorm-secret-tip-3-responders-for-view-notifications/#comment-201 thomasb Wed, 24 Feb 2010 21:44:04 +0000 http://www.gridlinked.info/?p=287#comment-201 Nguyen,Do not use the ObjectUtil.copy() method. You simply copy the reference to the interface. Here is a better refactoring for your business event class:public class SequenceEvent extends CairngormEvent { public function SequenceEvent(type:String, responder:IResponder=null) { super(type,false,false); this.responder = responder; } override pubic funciton clone():Event { return new SequenceEvent(type,responder); } }Note that you do NOT need to implement clone() unless you are expecting the event to bubble in the display hierachy. If you are dispatching directly to the business layer [using for example UMEvent::dispatch()] then clone() is not required. Nguyen,

Do not use the ObjectUtil.copy() method. You simply copy the reference to the interface.
Here is a better refactoring for your business event class:

public class SequenceEvent extends CairngormEvent {
public function SequenceEvent(type:String, responder:IResponder=null) {
super(type,false,false);
this.responder = responder;
}

override pubic funciton clone():Event {
return new SequenceEvent(type,responder);
}
}

Note that you do NOT need to implement clone() unless you are expecting the event to bubble in the display hierachy.
If you are dispatching directly to the business layer [using for example UMEvent::dispatch()] then clone() is not required.

]]>
By: Matthew Cliffordhttp://www.gridlinked.info/cairngorm-secret-tip-3-responders-for-view-notifications/#comment-196 Matthew Clifford Tue, 23 Feb 2010 17:21:07 +0000 http://www.gridlinked.info/?p=287#comment-196 Hi Thomas,I've successfully implemented the extensions into my Flex project, and am really pleased with it. My views can now all receive specific event notifications, which is great.One question to follow up, what is the correct best practice method for one view to directly dispatch an event to another view?Should the views have event listeners (which seems wrong to me in basic MVC terms), or should I go through the command layer and back again? If so, how would you suggest going about this, in simple terms?Kind regards,Matthew Hi Thomas,

I’ve successfully implemented the extensions into my Flex project, and am really pleased with it. My views can now all receive specific event notifications, which is great.

One question to follow up, what is the correct best practice method for one view to directly dispatch an event to another view?

Should the views have event listeners (which seems wrong to me in basic MVC terms), or should I go through the command layer and back again? If so, how would you suggest going about this, in simple terms?

Kind regards,

Matthew

]]>
By: Nguyenhttp://www.gridlinked.info/cairngorm-secret-tip-3-responders-for-view-notifications/#comment-195 Nguyen Mon, 22 Feb 2010 16:56:42 +0000 http://www.gridlinked.info/?p=287#comment-195 Hi Thomas,Thanks for your great article. I have tried your method by passing responder from view class to customer event class. However, I always get error when I tried to re-dispatch event. I already override clone() method in my custom event class but still.// Custom Event Class - clone() method package com.mydomain { import com.adobe.cairngorm.control.CairngormEvent; import flash.events.Event; import mx.rpc.IResponder; import mx.rpc.Responder; import mx.utils.ObjectUtil;public class SequenceEvent extends CairngormEvent {// Responder public var responder:IResponder;// Constructorpublic function SequenceEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false) { super(type, bubbles, cancelable); }// Overrideoverride public function clone():Event { var sequenceEvent:SequenceEvent = new SequenceEvent(type, bubbles, cancelable); sequenceEvent.responder = ObjectUtil.copy(responder) as IResponder;return sequenceEvent; } } }do you know what I'm doing wrong in here?Thanks Hi Thomas,

Thanks for your great article. I have tried your method by passing responder from view class to customer event class. However, I always get error when I tried to re-dispatch event. I already override clone() method in my custom event class but still.

// Custom Event Class – clone() method
package com.mydomain
{
import com.adobe.cairngorm.control.CairngormEvent;
import flash.events.Event;
import mx.rpc.IResponder;
import mx.rpc.Responder;
import mx.utils.ObjectUtil;

public class SequenceEvent extends CairngormEvent
{

// Responder
public var responder:IResponder;

// Constructor

public function SequenceEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false)
{
super(type, bubbles, cancelable);
}

// Override

override public function clone():Event
{
var sequenceEvent:SequenceEvent = new SequenceEvent(type, bubbles, cancelable);
sequenceEvent.responder = ObjectUtil.copy(responder) as IResponder;

return sequenceEvent;
}
}
}

do you know what I’m doing wrong in here?

Thanks

]]>
By: Matthew Cliffordhttp://www.gridlinked.info/cairngorm-secret-tip-3-responders-for-view-notifications/#comment-194 Matthew Clifford Fri, 19 Feb 2010 17:59:19 +0000 http://www.gridlinked.info/?p=287#comment-194 Thanks again...Could you explain in a little more detail the ApplicationInitializeEvent() method within the LoadUserDetails event class that you have created?How or where is that method called?Matthew Thanks again…

Could you explain in a little more detail the ApplicationInitializeEvent() method within the LoadUserDetails event class that you have created?

How or where is that method called?

Matthew

]]>
By: thomasbhttp://www.gridlinked.info/cairngorm-secret-tip-3-responders-for-view-notifications/#comment-193 thomasb Thu, 18 Feb 2010 22:57:49 +0000 http://www.gridlinked.info/?p=287#comment-193 Matthew, The best way to checkout the source code is using an SVN client; either standalone or a plugin to Eclipse/Flexbuilder.Go to this page for <a href="http://code.google.com/p/flexcairngorm/source/checkout" rel="nofollow">SVN checkout</a> details. See the <a href="http://code.google.com/p/flexcairngorm/source/browse/#svn/trunk/downloads" rel="nofollow">downloads section</a> for quick downloads also. Or you can directly download the <a href="http://flexcairngorm.googlecode.com/svn/trunk/downloads/CairngormExtensions.swc" rel="nofollow">SWC library</a> or the full archive/zip of the <a href="http://flexcairngorm.googlecode.com/svn/trunk/downloads/fb4_projectAndSrc.zip" rel="nofollow">Flashbuilder 4 library project</a>. Matthew,
The best way to checkout the source code is using an SVN client; either standalone or a plugin to Eclipse/Flexbuilder.

Go to this page for SVN checkout details. See the downloads section for quick downloads also. Or you can directly download the SWC library or the full archive/zip of the Flashbuilder 4 library project.

]]>
By: Matthew Cliffordhttp://www.gridlinked.info/cairngorm-secret-tip-3-responders-for-view-notifications/#comment-192 Matthew Clifford Thu, 18 Feb 2010 20:17:06 +0000 http://www.gridlinked.info/?p=287#comment-192 Hi Thomas,Superb article, thank you...Is there an easy way, or rather how do we actually correctly download the latest source for Cairngorm Extensions?From the website, I can browse each file, but I can't find a downloadable zip of everything?Many thanks,Matt Hi Thomas,

Superb article, thank you…

Is there an easy way, or rather how do we actually correctly download the latest source for Cairngorm Extensions?

From the website, I can browse each file, but I can’t find a downloadable zip of everything?

Many thanks,

Matt

]]>