Recommended pattern for handling communication between user controls / webform

Topics: Web Client Software Factory, UIP Application Block discussion
Jan 30, 2008 at 8:17 AM
Hello,
I have a web form that contains several user controls that communicate with each other.
I.e. when you select a value from a drop down in one user control some of the other user controls reload their values.

The implementation I've used now is taken from the MVPComposibility quickstart from the source code drop 26066.
That implementation uses a mediator to handle the communication. Each presenter has a model-class that sits between the controller and the presenter. The model exposes events that the mediator listens to, the mediator then calls methods on the other views models that notifies the corresponding presenters and updates their views.

This implementation is quite cumbersome when you get more communicating views since you have to add code to many places to make the interaction work. The extra model class seems a bit unnecessary, most of that code could be added to the controller I think.
I downloaded the MvpBundle-2007.11.27.2 and found that it uses another pattern for the communication.
Instead it handles all the communication through the controller and all the user controls, and the web form, shares an instance of the controller.

I like this solution better, but I’m wondering if this is the recommended way to do this.

One more thing, in the MvpBundle-2007.11.27.2 the web form listens to events from the user controls that they have finished loading and the sets the controller of each user control to the instance the web form has.

This seems like kind of a hack to me and I was wondering if this couldn’t be done with the object builder instead. I was thinking about adding a special kind of CreateNew attribute that takes a key as a parameter and creates an instance of the object that only exists for that request. Each consequent use of the attribute with the same key would retrieve the same instance.
What do you think about that solution to handle the controller wiring?

/Mats
Softgear AB