Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: controller and viewcomponent  (Read 8621 times)
mapuchu
Newbie
*
Posts: 3


View Profile Email
« on: September 25, 2009, 07:55:31 »

Hi,

I have a controller command which know and modify the viewcomponent of a mediator.
is it a good practice ?

btw, thanks for puremvc framework ; I appreciate it very much and have recommanded puremvc
to my boss and colleagues.
Logged
isragaytan
Full Member
***
Posts: 22


View Profile Email
« Reply #1 on: September 25, 2009, 12:23:03 »

Hi...

I think the best way and recommended is to do with notifications. Since the mediator and the command can listen and send notifications, the mediator can properly handle the notification. The command doesnt have to know about the viewcomponent. This job has to be done for the mediator.

Cheers
Logged
mapuchu
Newbie
*
Posts: 3


View Profile Email
« Reply #2 on: September 25, 2009, 03:06:00 »

ok, I get it clearer now.
so, if I understand, controllers don't call directly mediators' methods; they send notifications to mediators instead.
is what I say correct?

thanks.
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #3 on: September 27, 2009, 06:24:50 »

A command can work with a view component, but it is better for it to go through the Mediator, that way there is only one actor in the system responsible for knowing about that view component. Usually, you'll send a notification from the Command that the Mediator will respond to.

However there is always the possibility that you have many similar view components that implement a common interface, and a command that does something against that interface, such as decorating an icon. In which case it could be the other way around. A Mediator might send a reference to its view component in the body of a notification, which a Command receives, does the decoration and that's it.

-=Cliff>
Logged
mapuchu
Newbie
*
Posts: 3


View Profile Email
« Reply #4 on: September 27, 2009, 01:43:46 »

that's what i need! decorating fields depending on their contents is "bad", "acceptable", or "good".
and i prefer this be done by a controler than a mediator - thank you -
Logged
Pages: [1]
Print