tags:

views:

70

answers:

1

I have a main form with a left and right pane. The left pane displays a list of customers and I have a button the user clicks to show orders. When the user clicks this button I want to show the order details view described below in the right pane.

I have an order details form that will be displayed within the right pane of the main form and will show all the orders for the selected customer.

I have defined view interfaces for both views and there is a presenter for each view.

I want the order details to be able to get a hold of the selected customer so that it can obtain the orders for that customer.

How should I go about it? Event Aggregator? Composite Presenter?

A: 

Each pane is not a separate view. By doing that you are tying the specifics of the form to the presenter. The basic idea is that your editing a list of customers the presenter should not care how the form is setup.

Your two pane view should extract a list of customer from the presenter and use that list to fill out the left pane. Then when an item is clicked it ask the presenter for the list of orders the customers made and other details.

This approach will solve your problem as now there is a single view. When you click on something on the order and it needs to know the current customer you can refer to the tree view (or combo box, or list view, etc) to see what is the currently selected customer.

The trick to avoiding issues like this is to ask your self what happen if I make a new form that use completely different UI elements. Will the presenter have to be altered to reflect that? If the presenter does then you have tied it too closely to the implementation of the view.

RS Conley
Thanks again for your response. What if I planned to use this righthand pane to display other view related to other features?
David
In which case you need to alter to presenter to retrieve stuff like the what is the current customer from the view so the other pieces of the software can find out what is the selected customers. Also you want a state or status variable exposed by the presenter as to what type of view is currently loaded. The another alternative is to make the second view an observer of the first view. There is a separate interface that the tree view implement to let observers know what view is located and what is the currently selected item.
RS Conley