Last post Jul 31, 2005 07:31 PM by l_chateauv
May 16, 2005 10:50 PM|steph_unik|LINK
I try without any success to make the following code work in DNN 3.0.13. I took it from the following address:
http://blogs.wdevs.com/am/articles/532.aspx. If anyone is able to make it work it will be really appreciated!
PM or email me ;)
Sunny: Well, the way I handle it is to have my "Master" view implement both IModuleCommunicator AND IModuleListener. Then, when I load the slave views, I determine if they implement either of those interfaces. If so, I attach my own event handler for the
slave's ModuleCommunication event (the master responds to the slave's event). And in that handler the Master raises it's OWN Modulecommunication event that other modules can sink (the skin will never see the slave, so it can't sink events for it).
If the slave implements IModuleListener, then I hook up a Delgate to the slave's method and call it from my own OnModuleCommunication method.
It's a little confusing, but if you stare at it long enough, you'll see that the master is completely transparent. It handles communication from other modules as if it were the slave; and other modules are notified when a slave wants to talk.
Here's a snip:
objModule is the slave loaded with LoadControl().
.... ' HERE IS WHERE I HOOK UP THE SLAVES
If TypeOf objModule Is IModuleCommunicator Then
AddHandler CType(objModule, IModuleCommunicator).ModuleCommunication, AddressOf Me.OnSlaveModuleCommunicateEvent
If TypeOf objModule Is IModuleListener Then
Me.ModuleCommunicationDelegate = New OnSlaveModuleCommunicationDelegate(AddressOf CType(objModule, IModuleListener).OnModuleCommunication)
objModule.ModuleConfiguration = Me.ModuleConfiguration
..... HERE IS WHERE THE MASTER IMPLEMENTS BOTH INTERFACES
Public Event ModuleCommunication(ByVal sender As Object, ByVal e As DotNetNuke.ModuleCommunicationEventArgs) Implements DotNetNuke.IModuleCommunicator.ModuleCommunication
Public Sub OnModuleCommunication(ByVal s As Object, ByVal e As DotNetNuke.ModuleCommunicationEventArgs) Implements DotNetNuke.IModuleListener.OnModuleCommunication
If Not Me.ModuleCommunicationDelegate Is Nothing Then
.... HERE ARE THE DELEGATES AND EVENTS THE MASTER USES TO SIT BETWEEN THE SLAVES AND OTHER INTERESTED MODULES
Private Delegate Sub OnSlaveModuleCommunicationDelegate(ByVal s As Object, ByVal e As ModuleCommunicationEventArgs)
Private ModuleCommunicationDelegate As OnSlaveModuleCommunicationDelegate = Nothing
Private Sub OnSlaveModuleCommunicateEvent(ByVal sender As Object, ByVal e As ModuleCommunicationEventArgs)
RaiseEvent ModuleCommunication(sender, e)
May 17, 2005 06:03 AM|xpdit|LINK
well, please understand that the event exists ONLY UNTIL it is raised. then it is gone. if you dont handle the IMC request on the subsequent page load then that event is gone. (dont do it in the page init, becuase you cannot determine if the event is raised
IMC is a good way to do certain things, but it cannot and should not do everything.
make sure your events are handled in the first request after postback of the calling event, and IMC will find that object, raise it as an event to the specified event handler (you imc object listener).
if you are passing objects and not just text, let me know. this is something i watch closely, and still am having irregulatieies with objects passed through the IMC ("value" field.).
you MUST make sure that when using the data passed, it is happening after pageinit, hopefully during page load, or IMC event may not be raised yet whe nyou go to look for/handle it. also, if there are any post backs between the IMC event raising, and the
use, then it will not exist, as IMC is only pertinent to the next request, as is any event you raise.
May 17, 2005 12:55 PM|steph_unik|LINK
Could you post a small working sample with Master and Slave module IMC for DNN 3.0.13 it will help me and maybe other user very much!
A slave module loaded by the master who receive a events from a button in the slave module as in the code snip in my previous post.
May 18, 2005 01:11 AM|xpdit|LINK
i sure can. actually, i should slap myself for not updating my sample modules to 3.0 ... <SLAP>
I implemented the new IMC, which is based on Todd Mitchell's codebase, into the 2x dnn core, and that was fine (except for some value fields as objects, which i am still working on). so if you want to direct your questions etc to me, i wouldn't mind. I
have tested it alot, and i have used it alot. I had a pair of sample modules with a sender / listener modules. i will update this to 3.x and let you all know. if you want, ping me frequently and remind me to make some time in my busy busy week to do this.
good thing is it DOES work, and you just have to follow some pretty strict rules becuase you are operating in a part of the lifecycle of that request with some limited options. the IMC event handling falls intermittently between the init and render events,
which means that sometimes load does not recognise it. we are still nailing it down to why this happens.
thanks for your input.
Jun 27, 2005 10:26 AM|l_chateauv|LINK
Jul 28, 2005 08:21 PM|l_chateauv|LINK
Jul 31, 2005 07:31 PM|l_chateauv|LINK