views:

267

answers:

1

Can someone tell me what component in MVP - Supervising Controller variation has the responsibility for implementing logic related to the enablement/disablement of UI elements?

For example, I have a view that has a checkbox and a number of textboxes. Now 2 of the text boxes should only be enabled if the checkbox is checked.

Should the logic to control this be the responsibilty of the presenter or the model?

+1  A: 

Supervising Controller assumes that

  • View interacts with model for simple data binding
  • View is updated by Presenter and through data binding

So basically in order to find responsible component you need to identify who has enough information to do the update. If checked state of checkbox is directly mapped to Model then View is the right place to do it through data binding. If on the other hand the state is calculated by presenter as a result of reacting to user interaction then you can update View from Presenter.

Dzmitry Huba
Checked state of checkbox is directly mapped to model. So you are saying that it would be the views responsibilty to disable the 2 text boxes. Not sure though what you mean by 'through databinding'. Can you please explain. Thanks
David
For example, if your View shows list of Users and User object from model has boolean IsLocked property. According to Users list view you can select by checking checkboxes only unlocked users. In this case CheckBox.Enabled property will bound to User.IsLocked as it is pretty trivial logic. However if it state calculation is not trivial I suggest to put it into Presenter.
Dzmitry Huba