How to update / renew all views

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

I'll have a workitem containing a cuple of views which work on a particular object. After changing this object i like to update all views to display the new data.

What is the best way to update / renew all views ?
Feb 19, 2007 at 11:01 PM
Publication/Subscription?
Feb 20, 2007 at 1:48 AM
EventBroker event. How you go about detecting the state of the object that has been changed will depend on if your business object contains that functionality (IsDirty/IsNew). If not, then it will become something you will have to track internally in your Presenter.

Feb 20, 2007 at 10:38 AM
Thank you Silat, thank you Chris,

Of course my business object contains a property IsModified. So I'll pick up your suggestion and implement a Command named UpdateAllViews which work quite good. Except the first initialisation of my navigationService. See: http://www.codeplex.com/smartclient/Thread/View.aspx?ThreadId=7405

Any ideas ?
Feb 20, 2007 at 3:09 PM
I see you are wiring up the Click event handlers for your Commands in the OnViewReady part of your view. From your description it sounds like these CommandHandlers are directly related to buttons on the View itself (and not Toolstrip items).

CommandHandlers are best left to ToolStrip and MenuStrip items. When you have a button on a view, the best architecture (I think) is to have that view delegate to a presenter that would then fire an EventBroker event for anyone who needs to listen (or talk to a service if that's the case).

If you were to do that, you could get away from the problem of having to wire-up the click events for the CommandHandlers on the OnViewReady method, and that would help streamline your startup process.

Feb 20, 2007 at 7:10 PM
Thank you Chris,

Commands and buttons works great. Particularly with regard to Enabled / Disabled / Unavailable the Command.Status which also Enabled / Disabled / Unavailable the button.

I have noticing one problem with it, if you change the status of a Commad for which AddInvoker was not called.

See: http://www.codeplex.com/smartclient/Thread/View.aspx?ThreadId=7405