Complex BO question


Author
Message
Michael Cobb
Michael Cobb
StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)
Group: Forum Members
Posts: 26, Visits: 1K
Yes, I am overriding the GetCustomBindablePropertyDescriptors and adding my custom properties.  It might take me some time to try to get a sample together using the StrataFrame Sample database.   For now I'm ok with using Refresh() method to update the controls bound to custom fields that are set from the secondary BOs during the MainBO_Navigated event.
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Did you override the GetCustomBindablePropertyDescriptors method of the BO and add your custom property...or create a FieldPropertyDescriptor class for that property?  Is there any way that you could post a simple sample that reproduces your behavior.  That might be easier so that we can see what your code is doing first hand.  Thanks. Smile
Michael Cobb
Michael Cobb
StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)
Group: Forum Members
Posts: 26, Visits: 1K
Here's an example of one:

<Browsable(False), _

BusinessFieldDisplayInEditor(), _

Description("Property Tag ID"), _

DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _

Public Property [PropertyTagID]() As System.String

Get

Return _PropertyTagID

End Get

Set(ByVal value As System.String)

_PropertyTagID = value

End Set

End Property

This field is bound to a SF Textbox.  The value comes from a secondary BO, such as _BO1 in the generic examples used earlier in this thread.  The value is retrieved from the secondary BO in the MainBO_Navigated event and set there through the code as follows.

Me.PropertyTagID = _Property.TagId

_Property is the secondary BO.

None of the fields on the screen stay refreshed with the values retrieved from the secondary BOs unless I put the following code at the bottom of the MainBO_Navigated event:

Me.Refresh()

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
If you have your custom property setup properly it should be automatically refreshed on the screen properly.  What does your custom property look like?
Michael Cobb
Michael Cobb
StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)
Group: Forum Members
Posts: 26, Visits: 1K
You are correct.  It is retrieving the proper value but just not updating the custom field property with the updated value from _BO1.  The form is not displaying the updated values for the MainBO custom fields that are based on values stored in _BO1 and _BO2.  Based on this, I added lines to my MainBO_Navigated event to call the property sets for the custom fields after retrieving the data from _BO1 and _BO2.  Unfortunately, even though I call the Property Set and pass it the appropriate value, the field on the screen continues to display the value for the previous record.  Is there something I need to do to force the screen to update with the current custom field property value that is being set in the MainBO_Navigated event?
StrataFrame Team
S
StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
When the Navigated method is called, the record should be in the right location.  There is a Navigating event that gets raised just before the record is actually navigated, so it will have the old value.  However, you shouldn't have the previously navigated record if you're using the Navigated event.  If you put a breakpoint in the Navigated event handler, is the _MainBO.CurrentRowIndex of the business object set properly when you're trying to call the custom fill method on _BO1?
Michael Cobb
Michael Cobb
StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)
Group: Forum Members
Posts: 26, Visits: 1K
From your reply, I'm inferring that I should just load some record from within the MainBO_ParentFormLoading event so that the form will load properly, and then in the FormLoad event I would call any code to retrieve data based on user supplied criteria (this form will probably be launched from a search dialog).  Is this correct?

I'm still having a problem.  In MainBO, I have a call to a custom fill method for _BO1 like the following:  _BO1.CustomFillMethod(Me.Field).  The first 5 records in my sample do not have associated _BO1 records, and the last 3 records do.  When I get to the 6th record, the _BO1 data is not populated.  When I leave that record, the _BO1 data for record 6 appears with the record I navigate to.  In essence, as I navigate the records the form displays the values from the previous _BO1 record, not the current _BO1 record.  Does this mean that the parameter I'm passing isn't being updated with the current record's value in MainBO before it hits the Navigated event?  It worked before when I was calling a fill method for _BO1 within each Property Get, but as soon as I put the code to load _BO1 in the MainBO_Navigated event this problem began occurring.  I also removed all calls to load _BO1 from within the Property Gets (inefficient anyway though it did work), but still the records aren't in sync.

StrataFrame Team
S
StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
It's fine that you leave the population of _BO1 and _BO2 in the MainBO.Navigated and _BO1.Navigated events respectively.  All you need to do is test on the BO.IsEmpty property (which if you don't have, since it was added in 1.6.1, you can test .Count = 0) to make sure that there are records in the BO before you try to work with it.  Also, I would recommend populating the MainBO within the ParentFormLoading event.  The ParentFormLoading event fires before any of the controls are bound, so, if you fill MainBO within it, the Navigated event will fire when the MainBO is filled, and the other 2 business objects will then be filled within that event.  It would also be recommended to test the .IsDirty property in your custom business objects, because while you should normally have some records, you might run into a case where you legitimatly don't have any records, so you would need to prepare and test for that condition.
Michael Cobb
Michael Cobb
StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)StrataFrame Beginner (36 reputation)
Group: Forum Members
Posts: 26, Visits: 1K
Thanks for the advice.  Now I have some new issues.  If I put the code to load _BO1 and _BO2 in the MainBO_Navigated event, the application returns errors when I open the form.  I receive {"The CurrentRow could not be evaluated because the CurrentRowIndex is out of range.  Business object record count: 0.  CurrentRowIndex: -1."} when the MainBO custom property field that exposes _BO1.test1 tries to bind to the form.  Since the MainBO.Navigated event has not yet occurred, the property get fails.

Another complication is that _BO1 may not contain data matching MainBO, and _BO2 may not contain data matching _BO1.  Each is dependent on its predecessor.  In a SQL analogy, MainBO left joins _BO1 which left joins _BO2.

Anyway, what I really need is some way to make sure that MainBO is fully loaded before _BO1 and _BO2, and that the data binding occurs after all of them are loaded.  Then when I move through the records of MainBO, I need to be able to retrieve the appropriate values for _BO1 and then _BO2.

Any thoughts?

StrataFrame Team
S
StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
If you can fill all 3 and they stay in sync until you refill them again, then you could just write a custom Fill method on MainBO and have it fill all of the business objects in the necessary order.  However, if the data within _BO1 and _BO2 is dependent upon the selected record in the MainBO, then yes, putting the refill of _BO1 in the Navigated of MainBO and the refill of _BO2 in the Navigated of _BO1 would be your best bet.
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