determine businessobject on FormNavigated


Author
Message
Fabian R Silva, -
Fabian R Silva, -
StrataFrame User (317 reputation)StrataFrame User (317 reputation)StrataFrame User (317 reputation)StrataFrame User (317 reputation)StrataFrame User (317 reputation)StrataFrame User (317 reputation)StrataFrame User (317 reputation)StrataFrame User (317 reputation)StrataFrame User (317 reputation)
Group: StrataFrame Users
Posts: 153, Visits: 1.2K
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.
Reply
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
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! BigGrin
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search