PureMVC Architects Lounge

Announcements and General Discussion => General Discussion => Topic started by: bestbuyernc on July 06, 2010, 02:05:47

Title: PureMVC notification or Flash Event?
Post by: bestbuyernc on July 06, 2010, 02:05:47
This is probably a easy one but.. i am confused all of a sudden about how I should handle this scenario.  I have a UserManager component that is similar to the EmployeeAdminDemo.  Basically the view component has a mode property that controls weather certain buttons, fields are displayed and enabled.  If a user is editing his own profile then certain controls like, userID, status and role should be disabled.  Also, if a user is an admin or super user then they will have access to certain controls that a regular user will not have.  Should I be managing this property and the responses to its changes using the custom event way or should I use the PureMVC communication system to send notifications to the view component's mediator?  Or does this even make a difference?


Title: Re: PureMVC notification or Flash Event?
Post by: puremvc on July 07, 2010, 01:52:24
What I usually do is have the view component use binding expressions on the individual controls to manage their visibility or enablement. Or if there is a significant amount of binding going on (5 or more controls need to be hidden or shown according to a single expression), I'll instead use a view state that is controlled by binding.

So essentially, the view component can be intelligent enough to configure itself properly based on the data it is given. This, IMHO, is better than having another actor (like a mediator) puppet a dumb view component. The view component has no other reason to exist than to expose the data for view and/or manipulation, so it's going to have to know the data somewhat.