By Fabian R Silva, - - 7/15/2008
I have two BOs (a primary and a "not primary", I have to put a handler of primarybusinessobject.navigated to a method on a form to refresh the "not primary" child BO fill manually...
the question is if I have a property or something else that determine if the navigate object is the primary (the eventarg MicroFour.StrataFrame.Business.NavigatedEventArgs in the formnavigate event doesn't have a reference to the business object that raise the navigate)
pd: I not use the BO's property "parentrelationship" and "parentbusinessobject" because I inherited from a intermediate BO and this give me problems with the property (parentrelationship)... then I cut the parent - child features and handle the navigate / transaction stuff manually...
thanks for any idea on this.
|
By Paul Chase - 7/15/2008
Fabian,I "wrapped" the strataframe events that did not pass a sender into custom events that pass the sender though so I could tell where it came from. I'm not sure why they didnt pass the sender through #Region " Events"'---> Add events that mirror StrataFrame Events as they do not pass a sender so I can't tell which BO intitiated the eventPublic Event AL_Navigated(ByVal sender As Object, ByVal e As MicroFour.StrataFrame.Business.NavigatedEventArgs)Public Event AL_AfterAddNew(ByVal sender As Object, ByVal e As System.EventArgs)Public Event AL_AfterDeleted(ByVal sender As Object, ByVal e As MicroFour.StrataFrame.Business.AfterDeleteEventArgs)Public Event AL_BeforeDeleted(ByVal sender As Object, ByVal e As MicroFour.StrataFrame.Business.BeforeDeleteEventArgs)#End Region#Region " Wrapped Events"''' <summary>''' Wraps the After Add New event''' </summary>''' <param name="e"></param>''' <remarks></remarks>Private Sub BaseBiz_AfterAddNew(ByVal e As System.EventArgs) Handles Me.AfterAddNew'Bubble up th SF eventRaiseEvent AL_AfterAddNew(Me, e)End Sub''' <summary>''' Wraps the After Delete event''' </summary>''' <param name="e"></param>''' <remarks></remarks>Private Sub BaseBiz_AfterDelete(ByVal e As MicroFour.StrataFrame.Business.AfterDeleteEventArgs) Handles Me.AfterDelete'Bubble up th SF eventRaiseEvent AL_AfterDeleted(Me, e)End Sub''' <summary>''' Wraps the Befoew Delete event''' </summary>''' <param name="e"></param>''' <remarks></remarks>Private Sub BaseBiz_BeforeDelete(ByVal e As MicroFour.StrataFrame.Business.BeforeDeleteEventArgs) Handles Me.BeforeDelete'Bubble up th SF eventRaiseEvent AL_BeforeDeleted(Me, e)End SubPrivate Sub AL_BusinessObjectBase_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.DisposedEnd Sub''' <summary>''' Handle The is Dirty Changed Event to Enable Disable Buttons ''' </summary>''' <param name="sender"></param>''' <param name="e"></param>''' <remarks></remarks>Private Sub AL_BusinessObjectBase_IsDirtyChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.IsDirtyChanged'Nothing here for now this will enable us to trap for changes and then flip buttons' Base.Common.MainForm.HandleEditingStateChanged()End Sub''' <summary>''' Wraps the Navigated event''' </summary>''' <param name="e"></param>''' <remarks></remarks>Private Sub BaseBiz_Navigated(ByVal e As MicroFour.StrataFrame.Business.NavigatedEventArgs) Handles Me.Navigated'Bubble up th SF eventRaiseEvent AL_Navigated(Me, e)End Sub#End Region
|
By Greg McGuffey - 7/15/2008
I guess I'm confused. When you setup an event handler on a BO, it is BO specific normally, unless you are sharing the event handler. I.e. if you have two BOs on the form, PrimaryBO and NotSoPrimaryBO, then when you setup event handlers, it is specific to the BO:
// C#. primaryBO_Navigated and notSoPrimaryBO_Navigated are methods in the form class.
PrimaryBO.Navigated += primaryBO_Navigated;
NotSoPrimaryBO.Navigated += notSoPrimaryBO_Navigated;
' VB. Two choices:
AddHandler PrimaryBO.Navigated, AddressOf primaryBO_Navigated
AddHandler NotSoPrimaryBO.Navigated, AddressOf notSoPrimaryBO_Navigated
' Or directly at the method:
Private Sub primaryBO_Navigated(e As NavigatedEventArgs) Handles PrimaryBO.Navigated
' handle primary BO stuff
End Sub
Private Sub notSoPrimaryBO_Navigated(e As NavigatedEventArgs) Handles NoSoPrimaryBO.Navigated
' handle not so primary bo stuff
End Sub
So, you'd always know the BO, because the code will only react to the navigation on the BO that it is subscribing to.
Now if you are sharing the event handler for both, then, you'd have a problem...but one that is easily fixed. Put the shared code in a private method, with an argument that is the BO being used. Then just use two event handlers to call the common method:
' Common method that does work, based on BO
Private Sub NavigatedHandler(bo As BusinessLayer)
' Test on BO type to figure out what to do
If bo.GetType() Is Me.PrimaryBO.GetType() Then
End If
End Sub
' Use two event handlers that call the common method
Private Sub primaryBO_Navigated(e As NavigatedEventArgs) Handles PrimaryBO.Navigated
Me.NavigatedHandler(Me.PrimaryBO)
End Sub
Private Sub notSoPrimaryBO_Navigated(e As NavigatedEventArgs) Handles NoSoPrimaryBO.Navigated
Me.NavigatedHandler(Me.NotSoPrimaryBO)
End Sub
Hope that helps!
|
By Greg McGuffey - 7/15/2008
I really need to read the posts...FormNavigated... Paul's idea is a good one!
|
By Trent L. Taylor - 7/15/2008
All good stuff! Thanks, guys!
|
By Fabian R Silva, - - 7/16/2008
thanks Paul and Greg for the great tips, about the wrapper I see that the post http://forum.strataframe.net/FindPost12487.aspx have and awesome example of how to do reports with datasets and BBS's and have the handler stuff on the code that Paul and Trent post I see what I do about the formnavigate / navigate / handlers stuff.
thanks Paul and Trent for the examples on that post about reporting, appears to be very usefull and soon I have to do something of that
|
By Trent L. Taylor - 7/17/2008
One thing that you may want to download is the most recent 1.6.6 beta as there is now a new Custom Business Binding Source and template that makes it VERY easy to create reporting objects. We will post more information and samples about this over the next few weeks, but that would be a good place to start.
|
By Fabian R Silva, - - 7/18/2008
thanks for the advice Trent, I will see it, sound interesting. Thanks
|
|