Where is the best place to initialize ...

Topics: CAB & Smart Client Software Factory
Feb 19, 2007 at 4:24 PM
Hello NG,

I am locking for a place to initialize a navigationService for all views in a module. WorkItemController.Run() do not work because all views must have done OnViewReady() before initialize navigation.

Can someone please point me to the right place ?
Feb 20, 2007 at 11:57 AM
I do not understand why you need to have done the OnViewReady() before the initialization of the service.
Would you explain me that, so I can understand your scenario.

Thanks,
Feb 20, 2007 at 12:40 PM
Hi jonston85,

In a Module i have a couple of views. To guide the users i add a view where the user can select a tasks, and a NavigationService which Enable/Disable the possible commands assosiated with the buttons on the views ( e.g next / previous buttons ). Each view do some 'WorkItem.CommandscommandName.AddInvoker(button_item, "Click");' This is done in 'OnViewReady()'. To initialise my NavigationService all commands has to be connected with thier buttons/menuItems because in this method i disable some of these buttons by 'WorkItem.CommandsCommandNames.ButtonNext.Status = CommandStatus.Disabled;' ( depending on the state )
So, where is the place to put the call for StartNavigationService() ?
or have i made a big design fault ?

Feb 20, 2007 at 3:04 PM
If I did not misunderstand, your idea is to create something like a workflow for your application, this means, use a service to control what the user can or cannot do at every moment.

So in the view that shows the tasks the user can do, you could have one button for each action. For example:

1. CreateaccountButton.
2. ViewAccountsButton.
3. Etc.

When a button is clicked, it fires a specific command for its action (for example CreateAccountCommand).

The ModuleController, listens to the Command, Adds and shows the corresponding the view. (Previously you should have added the NavigationService to the Services list of the Workitem and started it)

At the end of the XXXViewPresenter.OnViewReady method you should fire an event (with the xxxViewName as a parameter) that the NavigationService should be listening.

After this, the NavigationService do its work for the XXXview and fires another event that the presenter of the XXXView should be listening. This event contains a message telling which commands and controls enable/disable in the XXXView.

I hope this helps you.

Jonathan Menasches.
http://staff.southworks.net/jony



Feb 20, 2007 at 6:56 PM
Thank you Jonathan,

You and Chris suggest two possibilities:

1) Query the Navigation service from the views to enable/disable the commands/buttons
2) Send a message from the navigationService to the Views to ... (see above)

Since the navigaton works fine if I start ( initialise ) it by an extern event ( menuItem )( I think the main problem is that i disable commands for which AddInvoker have't run )
I stagger between :
2) Send a message from the navigationService to the Views and there i call all the AddInvoker
3) I'll do the AddInvoker stuff in the presenter by
  protected override void OnViewSet()
  {
  	base.OnViewSet();
  	View.InitialiseView();  // calls _presenter.AddCommandInvoker for all Buttons
  }
which run much earlier as Presenter.OnViewReady or View.OnLoad.
The NavigationService can still fire all the events to activate the views and Enabled / Disabled / Unavailable all cammands in all views.

Thank you

Uwe Lesta