Event publish and subscription issue

Topics: CAB & Smart Client Software Factory
Dec 30, 2005 at 7:33 PM
originally posted by: SUBATBLOOMINGTON

Hi,

we have a requirement in which the business service component should publish an event which needs to be handled at the user interface level. when we are publishing the event in the component its not been handled by the subscriber.

please let me know whether this is possible with cab event broker mechanism??

any help please
Dec 31, 2005 at 8:06 AM
originally posted by: BradWilsonMSFT

I don't understand what "handled at the user interface level" means. Can you be more explicit?
Dec 31, 2005 at 9:31 AM
originally posted by: SUBATBLOOMINGTON

Thanks for your reply. my question is whether its possible to use the event broker mechanism with model components being the publishers and the user controls being the subscribers. let us say the employee business class publishes the employeename changed event and the employee details user control subscribes to the above event and displays the message when the above event is triggered.

please help us
Dec 31, 2005 at 11:50 AM
originally posted by: BradWilsonMSFT

Yes, that's possible. There are no restrictions on which classes can be publishers and which can be subscribers.
Dec 31, 2005 at 12:02 PM
originally posted by: SUBATBLOOMINGTON

Thanks for your reply.

but when we do that the user controls are not catching the events published by the model components through event broker mechanism but the same works with workitem/usercontrol combination

any help
Dec 31, 2005 at 12:19 PM
originally posted by: BradWilsonMSFT

Make sure the controls are decorated with SmartPart. This is what tells CAB that the control is participating in the CAB infrastructure.
Jan 1, 2006 at 4:27 PM
originally posted by: SUBATBLOOMINGTON

Thanks for your reply. my user control will trigger a textbox changed event and i want to handle the same in my main shell. its not working...

user control code:

<SmartPart()> _
Public Class ucScreen2 : Inherits UserControl
<EventPublication("eventtopic://textboxchanged", PublicationScope.Global)> _
Public Event textboxchanged As EventHandler

Private Sub ucScreen2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub



Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
RaiseEvent textboxchanged(sender, e)

End Sub



Mainshell container code:

<EventSubscription("event://textboxchanged")> _
Public Sub textboxchanged(ByVal sender As Object, ByVal e As EventArgs)
MessageBox.Show("txtchanged")

End Sub

please help me
Jan 1, 2006 at 4:36 PM
originally posted by: eugeniop

The publisher is "eventtopic://textboxchanged" and the subscriber is "event://textboxchanged". Note event and eventtopic, they are different.
Jan 1, 2006 at 4:59 PM
originally posted by: SUBATBLOOMINGTON

Thanks for your reply. i have corrected it works but still facing problem over the code snippet

i have modified the BankTeller quick start exercise to learn for event broker mechanism. basically i have added an event to be triggered whenever the zipcode of the customer changes

following code changes done at Customer.vb class at BANKTeller / Businessentities
----------------------------------------------------------
<EventPublication("topic://Bankteller/CustomerZipChanged")> _
Public Event CustomerZipChanged As EventHandler
-----------------------------------------------------------


Now i am triggering the event


Public Property ZipCode() As String
Get
Return innerZipCode
End Get
Set(ByVal value As String)
innerZipCode = value
RaiseEvent CustomerZipChanged(Me, EventArgs.Empty)
End Set
End Property


Now my shell container is a subscriber to this event

i made the following changes at the Bankshellform.vb

<EventSubscription("topic://Bankteller/CustomerZipChanged", Thread:=ThreadOption.UserInterface)> _
Public Sub OnStatusUpdates(ByVal sender As Object, ByVal e As EventArgs)
toolStripStatusLabel1.Text = "customer zip changed"
End Sub

any help?