CommandHandler not called always

Topics: Mobile Client Software Factory
Jul 26, 2007 at 3:58 AM
Hi there,

I have a number of WorkItems (LogonWorkItem, JobsWorkItem and DetailsWorkItem) that all are direct children of RootWorkItem. The each have corresponding Views and Presenters. The LogonView contains a button and in LogonPresenter.cs I have the following line:

rootWorkItem.Commands"uie://btnLogon".AddInvoker(view.LogonButton, "Click"); //Where _view is LogonView and _rootWorkItem is what it says

In my JobsWorkItem I have the following handler:

CommandHandler("uie://btnLogon")
public void OnLogonClick(object sender, EventArgs e)
{
RootWorkItem.Workspaces"mainTabWorkspace".Activate(_view);
}

which is called successfully whenever I tap the Logon button.

I inserted a similar handler in my LogonWorkItem (just to see what would happen):

//Doesn't get called. Why??????
CommandHandler("uie://btnLogon")
public void OnLogonClick(object sender, EventArgs e)
{
RootWorkItem.Workspaces"mainTabWorkspace".Activate(_view);
}

which as the comment says, is never called when I tap LogonButton.

I want to understand why this is not called. I am new to the MCSF so there is obviously something I don't understand about Commands and their handlers.

Could someone please explain it to me?

Many thanks...

Robert
Jul 26, 2007 at 2:08 PM
Edited Jul 26, 2007 at 2:09 PM
Hi!

I have a question for you: is your LogonWorkItem workitem being added? Something like

workItem = WorkItem.WorkItems.AddNew<ControlledWorkItem<LogonWorkItem>>();

In case it’s not, that would be the explanation for that behavior. If in fact you are indeed adding the LogonWorkItem, then could you detail a bit more your modules structure?

Hope it helps!

Luciano G. Panaro
http://staff.southworks.net/lpanaro
Jul 26, 2007 at 11:02 PM
Hi Luciano,

Thanks for responding to my post. I appreciate your assistance.

Please note that this is the MCSF not the SCSF if that makes any difference.

Yes, my workItem is DEFINITELY being added (Ichecked with the debugger). Not only is the AddNew executed, but I checked that OnRunStarted in LogonWorkItem.cs is also executed. Here is the code that is definitely executed...

LogonWorkItem wi1 = RootWorkItem.WorkItems.AddNew<LogonWorkItem>();
wi1.Run();

On the structure of my modules, I have only one Module LogonModule containing three parallel WorkItems: LogonWorkItem, JobsWorkItem and DetailsWorkItem which are all added and run at the same time by the ModuleInit.

My LogonPresenter adds the command invoker for the button in question and there are command handlers in the JobsWorkItem and LogonWorkItem. The JobsWorkItem fires, but the LogonWorkItem handler is ignored. The code for both command handlers is identical (It was copied and pasted)

What other information do you need?
Thanks again for your assistance with this.

Robert