Dynamically added Tabs

Topics: CAB & Smart Client Software Factory
Jun 28, 2007 at 8:43 AM
Edited Jun 28, 2007 at 8:44 AM
I have to implement a TabWorkspace using SCSF that is capable of hosting different Views which can be added and removed by the user. The views show details for specific business entities.
My problem is to pass the corresponding business entity to a view. Since the views are added and removed dynamically to the WorkItem I dont know how to use dependency injection on the presenter, except by using one WorkItem for every view. But that does not seem like a good idea. Passing the business entities by te view's constructor seems even worse.
Do I have to implement my one Workspace?
Any ideas? Thanks.

PS.: I know that normally tabs are not the solution of choice for such a problem in CAB, but so it is written, so shall it be done.
Jun 28, 2007 at 1:54 PM
Used a new WorkItemController for every view that is added. Other solutions seemed lick a hack.
Jun 28, 2007 at 3:00 PM
Why not create a service that manages the buisness entities, then inject that service into the presenter for each view? Then the service can manage entity instantiation or retrieval whenever the corresponding view is dynamically created. That is how I do it, and is alot cleaner and less overhead than instantiating a new workitem for each view.

Jun 28, 2007 at 4:50 PM
It sure sounds cleaner, but how do you get map the data in the service to the view? Means, how does the presenter know which data to get from the service?
Jun 28, 2007 at 8:15 PM
Each presenter/view is hardcoded to work with a certain entity or set of related entities. It sounds like maybe you are trying to use a single view and presenter to show different unrelated entities. If so then what is the purpose of using MVP pattern? =)
Jun 29, 2007 at 7:41 AM
Perhaps you use only one instance of a specific entity at a time? I have several views for different instances of the same entity open a the same time. That is the root of my mapping problem. So the presenter has to have information which instance to get, not which entity.
Sorry. Should have made that clear in the first place. Thanks anyway.
Jul 2, 2007 at 6:14 PM
oh ok yeah I misunderstood, in that case you do need seperate workitems and use a service to track which workitem is active, take a look at chris holmes uiservice example he posted on his blog a while back (www.chrisholmesonline.com)