It requires a new command class because the command classes I currently have
update the two views separately. The requirement is not always for the view
to be updated simultaneously, so they each have their own command class.
The controller looks something like:
addCommand("updateViewOne", ViewOneCommand());
addCommand("updateViewTwo", ViewTwoCommand());
So these views can be updated without updating the other. What I want to
happen now is that when I have added a product successfully, is for both
command classes to be fired, therefore adding the lines below to the
controller:
addCommand("productAdded", ViewOneCommand());
addCommand("productAdded", ViewTwoCommand());
So ideally, the component that adds the command will not have know the
"updateViewOne" event or the "updateViewTwo" event. Nor should there be a
command to handle a "productAdded" event, I just want to define which view
to update through the front controller only. Therefore, if either of the
previous views no longer required updating when a product was added, or a
new view required updating, all I would need to change would be the
definitions in the controller.
Mike.
-----Original Message-----
From: Alex [mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: 04 February 2005 12:47
To: [email protected]
Subject: RE: [flexcoders] Cairngorm Event to Command
Not sure why it requires to create a new command class.
onResult function in your command class that is assigned with "add product"
event would be something like
public function onResult( event : Object ) : Void
{
var view1ViewHelper =
ViewLocator.getInstance().getViewHelper( "view1" );
var view2ViewHelper =
ViewLocator.getInstance().getViewHelper( "view2" );
view1ViewHelper.doSomethingInView1();
view2ViewHelper.doSomethingInView2();
}
Alex.
-----Original Message-----
From: Michael Herron [mailto:[EMAIL PROTECTED]
Sent: Friday, February 04, 2005 3:39 PM
To: [email protected]
Subject: RE: [flexcoders] Cairngorm Event to Command
Yes that would certainly work, but that would involve creating a new command
class. I was wanting to re-use the command classes that are currently being
used, but just fire them both for the same event.
Although your solution does seem more elegant that broadcasting multiple
events.
-Mike
-----Original Message-----
From: Alex [mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: 04 February 2005 12:11
To: [email protected]
Subject: FW: [flexcoders] Cairngorm Event to Command
Hi Mike,
I presume nothing prevents you from accessing two different views via
ViewLocator singleton within one command.
Regards,
Alex.
-----Original Message-----
From: Michael Herron [mailto:[EMAIL PROTECTED]
Sent: Friday, February 04, 2005 2:48 PM
To: [email protected]
Subject: [flexcoders] Cairngorm Event to Command
Hi all
Just a quick question about using cairngorm:
In my application when a product has been added, I wish to broadcast a
"product added" event and have it picked up by two separate command classes
that will update two separate views. Unfortunately, when the event is
broadcast, it only seems to be picked up by the command class that was
registered last in the controller.
To get round this I am having to broadcast two separate events specific to
the two views once a product has been added. Obviously, this doesn't provide
as high a level of de-coupling as I would like.
Has anyone else come across this problem? Am I doing something wrong or is
this a know "quirk"?
Cheers,
Mike
Yahoo! Groups Links
Yahoo! Groups Links
Yahoo! Groups Links
Yahoo! Groups Links