PureMVC Architects Lounge

Announcements and General Discussion => General Discussion => Topic started by: mapuchu on September 25, 2009, 07:55:31



Title: controller and viewcomponent
Post by: mapuchu 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.


Title: Re: controller and viewcomponent
Post by: isragaytan 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


Title: Re: controller and viewcomponent
Post by: mapuchu 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.


Title: Re: controller and viewcomponent
Post by: puremvc 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>


Title: Re: controller and viewcomponent
Post by: mapuchu 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 -