Print Page | Close Window

[SOLVED] Inter-module / Inter-view Communication

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=478
Printed Date: 11-Jun-2026 at 4:35pm


Topic: [SOLVED] Inter-module / Inter-view Communication
Posted By: Linguinut
Subject: [SOLVED] Inter-module / Inter-view Communication
Date Posted: 08-Oct-2007 at 11:55am
I have a view in a module that lists in a grid a certain entity (Parts).  I have another view in the same module that add/edits a related entity (Work Order).  Is it possible to create a new work order from the parts list view, then open the Work Order view to the newly created work order?  If so (and I have high expectations that this is easy to do), how do I go about this the CAB way?
 
Thanks!
Bill



Replies:
Posted By: Bill Jensen
Date Posted: 08-Oct-2007 at 2:49pm
At first glance, this sounds similar to the way SalesOrders are handled in Cabana.  The whole purpose of the EntityManager structure is to provide a mechanism to keep multiple editors in sync without round-trips to the server.
 
Bill J.


Posted By: Linguinut
Date Posted: 08-Oct-2007 at 3:53pm
As I understand Cabana, there is a separate SharedEditor module that is accessed via an EntityEditor service.  While this is a fine (and quite complicated) solution, I would like to take advantage of views that are already built.  I have a view in a module that is designed to add/edit/delete an entity.  How do I access that view from another view (or even module) within the application?


Posted By: Bill Jensen
Date Posted: 10-Oct-2007 at 12:45pm
You're right, the SharedEditor module is a bit complicated.
 
If you're wanting to pop up a WorkOrder view in a separate window, you can add it to the WindowWorkspace (with appropriate SmartPartInfo).
 
If you already have a WorkOrder view, you somehow have to get its data source set to the newly-created WorkOrder.  You could pass this information in the ViewContexts of the two views.  There would need to be a common controller that knows about both views.
 
I'd think carefully before trying to sync between modules, but if it were necessary, I'd probably use a CAB EventTopic.
 
Bill J.


Posted By: Linguinut
Date Posted: 10-Oct-2007 at 12:51pm

Utilizing the event broker...that is what I was researching.  It seems like the appropriate solution.  I'll update here once I get it working.  I am still working through the details.



Posted By: Linguinut
Date Posted: 11-Oct-2007 at 8:07am
I wonder if any of these people who are writing about the EventBroker with EventPublication / EventSubscription have really, actually, successfully written a viable communication.  NONE of their examples work...I have tried at least half a dozen scenarios.  Perhaps, there is some other kind of hindrance from the DevForce/CAB combo.
 
Any tips or tricks about the EventBroker syntax, especially within DF/CAB, would be welcome.
 
 


Posted By: Linguinut
Date Posted: 11-Oct-2007 at 8:24am
This is the best example that I found (copied from http://www.codeproject.com/useritems/XSModuleCompMppr.asp - http://www.codeproject.com/useritems/XSModuleCompMppr.asp ):
 
=========================
Event Publication

The publication handler itself...

[EventPublication("evt://XS/Generic/Foo")]
public event EventHandler<DataEventArgs<string>> BroadcastFoo;

Public method for invoking the publication handler from referring classes. While not required for events that should not be invoked except by the publishing class itself, if appropriate, provides an interface for referring classes that may also require invocation of the event, such as a view that may invoke an event defined on its owning presenter...

public void DoBroadcastFoo(object sender, string thisMessage)
{
   
this.BroadcastFoo(sender, new DataEventArgs<string>(thisMessage));
}

Event Subscription

[EventSubscription("evt://XS/Generic/Foo")]
[
EventSubscription("evt://XS/Generic/Bar")]
public void OnReceiveGeneric(object sender, DataEventArgs<string> e)
{
    myObject.MyMethod(e.Data);
}

=========================
 
Two namespaces must be referenced (not mentioned in article!):
Microsoft.Practices.CompositeUI.EventBroker
Microsoft.Practices.CompositeUI.Utility
 
I have not finished testing, but so far, I am getting no build errors. Smile


Posted By: Linguinut
Date Posted: 11-Oct-2007 at 9:59am
This is working.  I will utilize the EventBroker in many places...nice feature of CAB!!



Print Page | Close Window