Question

I'm using Smart Client Software Factory 2008. In the module controller, I have code that creates a new child controller only if it hasn't been created, by doing something like the following:

Dim key = "Item-" + item.ID.ToString()
Dim childWorkItem = Me.WorkItem.WorkItems.Get(Of ControlledWorkItem(Of ItemWorkItemController))(key)
If childWorkItem Is Nothing Then
    childWorkItem = Me.WorkItem.WorkItems.AddNew(Of ControlledWorkItem(Of ItemWorkItemController))(key)
Else
    childWorkItem.Activate()
End If

Multiple items reuse the same key, so when that action is triggered, it shows the tab instead of creating a new instance of it. This works great.

However, there is one drawback. Once activated, I need to run a check within that item's presenter. So I need to call a method on the presenter. Is there a way to invoka a method on the presenter, or is there an event that runs on the view when the work item is activated? I'm not sure how to make that happen?

Thanks.

No correct solution

OTHER TIPS

If you are using a Smart Part as your View you should be able to accomplish this using the IWorkspace.SmartPartActivated event.

This is how I have it setup in my project. I apologize, my code is all in C# but you should be able to apply it in VB relatively easily.

The WorkItemController class has the Activate method setup like this

ISmartPartView _smartPartView

public void Activate()
{
   IWorkspace contentWorkspace = this.WorkItem.Workspaces[WorkspaceNames.ShellContentWorkspace];
   contentWorkspace.Activate(_smartPartView);
   WorkItem.Activate();
}

In the ISmartPartView Presenter class you should be able to create a handler for the SmartPartActivated event like this:

IWorkspace contentWorkspace = this.WorkItem.Workspaces[WorkspaceNames.ShellContentWorkspace];
contentWorkspace.SmartPartActivated += workSpaceSmartPart_ActivatedHandler;

In the workSpaceSmartPart_ActivatedHandler event handler, you can check the SmartPart being activated and if its your ISmartPartView class you can run the desired code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top