DefaultValues and Disabled Controls

Topics: Developer Forum, User Forum
Aug 13, 2007 at 2:03 PM
Hi all
I'm working with web client software factory which is using mvp. So sorry if this is the wrong place to ask this question.

If I understand mvp framework correct, then neither the gui knows something about the presenter nor the presenter knows more about the gui than is specified in the Interface, correct? Not the gui (or the corresponding code-behind class) gets the data but the data is delivered from the presenter to the gu. Only the presenter has knowledge about the deeper layers of the application an thus pushs the data to the gui, correct?

Under these circumstances im asking me what is a good aproach to implement the following two requirements:
- Default values (e.g. in a dropdownlist set a default language to german if the user surfs from germany on my page)
- Enabled/Disabled controls (e.g. if the user comes from germany, so a dropdownlist 'state' is not required)

For both of these requirements either the code-behind class has to know about data or the presenter has to know what for controls are on the gui. But both of these seems for me to violate the idea of mvp, doesn't it? What is a good solution for this two requirements?

Thank you for your answer.
Best regards

Aug 14, 2007 at 2:21 PM
I´m not sure how this is implemented in WCSF, but what I´d do is:
-Default Values - This one is easy since the presenter CAN set values in the view without know about the controls. In your case I´d have a:
AvailableLanguagesEnum Languages {get;set;}
in the contract, so the view would implement it parsing the selected value in the dropdown.
This way the presenter can get values in the drop-down or set them.

In the case of Enabled/Disabled Controls, NMVP offers a IsReadOnly property that ALL views implement, and a convenient HostPresenter.SetReadOnlyMode() method, so the cascading is done for you, but you could always set a ViewState"IsReadOnly" and check it on views (not nice though lol).

Thanks for your interest,
Bernardo Heynemann