CABs way of handling smart parts comm and data

Topics: CAB & Smart Client Software Factory
Mar 24, 2006 at 10:16 AM
originally posted by: ChrisHolmes

Two parts to your question:

First, communication is handled through the EventBroker and Commands (depending on what needs to publish). So, imagine you have a WorkItem with two Views, ViewA and ViewB. Each has it's own Presenter, PresenterA and PresenterB.

User clicks a button on ViewA which calls a method on PresenterA which then calls an event it publishes. PresenterB subscribes to this event and then does whatever it needs to do (maybe it updates its own view, maybe it does something else).

Second, data is shared via the WorkItem's State bag. There is a class in the CAB called Controller that your Controllers/Presenters can subclass which gives you access to the parentWorkItem's State.

Hierarchy map:

WorkItem (contains State with some data object in it)

ViewA
PresenterA : Controller

ViewB
PresenterB : Controller



Via the subclassing of the Controller class, PresenterA and PresenterB now have access to the object in the WorkItem's State bag. Going back to my first example where a user presses a button on ViewA, PresenterA then updates the object in the State bag with the new values from ViewA. It publishes an Event that the WorkItem subscribes to telling the WorkItem to save the object in the State bag to persistant storage via a Service. The WorkItem does this, then publishes its own event telling all Views to update themselves. PresenterA and PresenterB subscribes to this Event, so they grab the object from the State bag (which now has new data in it) and update their Views.
Mar 24, 2006 at 11:18 AM
originally posted by: siamb

Hi,

I just attended the 2.5 day SC-BAT Training.

I have a question if anyone could explain in any way of the following:

1) How does CAB's SmartPart modules magically talk/communicate with eachother. (like a walk through). I know that CAB has its all powerful Event Broker, even/subscription services, etc...

for example) how does CAB magically handle 2 smart parts talking to eachother; meaning sharing data, etc. I understand the aspect that the smart parts have to be un-aware of other existing modules too....

I remember during the training that they had us do something like this for the extra credit portion of day 2 labs.