Three views, one WorkItem - is this right?

Topics: CAB & Smart Client Software Factory
May 9, 2007 at 10:03 AM
I'm trying to figure out the best way of managing the interactions within one use case that contains three views (I suspect this is a fairly familiar requirement).

View CaseSearchCriteria collects criteria, runs a search and then invokes CaseBrowse to show them, (currently via an event)
View CaseBrowse lists a set of cases. It can be shown in a number of modes, e.g. as a response to a search, or in a browse mode to see all cases.
View CaseEditUpdate collects data for a single case with Save/Cancel buttons. It is invoked either from an edit button on CaseBrowse or as an Add New Case menu item (on the shell). After a successful save it invokes CaseBrowse to show the cases added today.

So, my questions are:
I have currently got one WorkItemController to manage all three views, is this the best way?
How do I tell a view what mode it should work in (e.g. should Browse show tdoay's cases or a search result)? Should I expose a Mode property on the view? I would have thought it better to be on the presenter (since it's a property that should effect any view the presenter might implement), but there is no direct access to the presenter when adding or getting the view.

I have got eventsubscribers on the CaseWorkItemController, so that it can check to see if a requested view has already been created and show it appropriately; is this ok?

Has anyone got a good pattern to suggest?
Coordinator
May 9, 2007 at 1:40 PM
You can create the presenter yourself instead of using [CreateNew]. Something like this:

ThePresenter presenter = new ThePresenter( mode );
WorkItem.Items.Add( presenter, "ThePresenter" );

Then in your view you will have this instead of CreateNew:

[ComponentDepdendency("ThePresenter")]
public ThePresenter Presenter {
  get ..
  set ..
}

Matias
http://staff.southworks.net/blogs/matiaswoloski
May 10, 2007 at 2:57 PM
Brilliant, that works fine for singleton views, but is there a way of doing something similar when I need multiple instances of the same view/presenter? I need this for another part of the app - where users may browse details of two objects simultaneously and swap between them.

Or...am I missing something here, I'm always thinking that I should AddNew<MyView>, in code, then tell it what I want it to do. This all feels much harder than it needs to be.