Navigate on Form causes dirty BO


Author
Message
Doug Birtell
Doug Birtell
StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)
Group: Forum Members
Posts: 33, Visits: 64
I have created a SF Maintenance form that maintains a table.  The form does have combo boxes on it that use other BO's.  All that works fine.  I have 12 rows of data in the main table.

The issue is that when run the form, and try to navigate using the toolstrip navigator, it stops after navigating to the second record and no longer allows navigation through the rest of the record set (which via debugger, and Browse, all 12 rows DO exist in the BO).  When I then try to close the form, it has set the main BO to isDirty even though no editing has taken place bythe user (form).

The first 3 columns of the table comprise the PK and ALL columns on the BO are now set to "Return Alternate on Null" with a value.  3 columns on the table allow nulls, and are null in the database table.  I was able to add all 12 records using the SF form created. 

I do have 1 column that does not allow null, that is programatically set, which is the "date added". And the only way I could get it to work was to set the "Return Alternate on Null" property in the BO Mapper.

I know this has something to do with the combination of the database table allowing nulls, and the BO setting of "Don't Allow Nulls", "Return Alternate on Null", "Return Alternate on Null / Set Alternate on Null".  It seems like I have yet to find the combination that works.

??????????????

Peter Denton
Peter Denton
StrataFrame Novice (109 reputation)StrataFrame Novice (109 reputation)StrataFrame Novice (109 reputation)StrataFrame Novice (109 reputation)StrataFrame Novice (109 reputation)StrataFrame Novice (109 reputation)StrataFrame Novice (109 reputation)StrataFrame Novice (109 reputation)StrataFrame Novice (109 reputation)
Group: Forum Members
Posts: 77, Visits: 787
G'day

The issue is that when run the form, and try to navigate using the toolstrip navigator, it stops after navigating to the second record and no longer allows navigation through the rest of the record set (which via debugger, and Browse, all 12 rows DO exist in the BO).  When I then try to close the form, it has set the main BO to isDirty even though no editing has taken place bythe user (form).

The first 3 columns of the table comprise the PK and ALL columns on the BO are now set to "Return Alternate on Null" with a value.  3 columns on the table allow nulls, and are null in the database table.

I'm pretty certain the reason the Main BO is dirty is that the Nulls from the database are now the value you have set them to "Return Alternate on Null" with the Business Object Mapper (BOM), hence a change that needs to be saved.

We set all the value type fields to Nullable Generic in the BOM, and accessing the values of such fields are handled in code as follows

If MyBO.MyNullableGenericValueType.HasValue Then
    MyVar = MyBO.MyNullableGenericValueType.Value
End If

string and timestamp fields we set to return alternate on null in the BOM with values "String.Empty" and "Nothing" respectively. We have generally tried to minimise nulls in the database, and so don't have string fields that can be null.

I hope this helps with part of your problem.

Peter

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
Peter has a very good point.  Try his suggestion and if it doesn't resolve your issue then we can look at something else.
Doug Birtell
Doug Birtell
StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)
Group: Forum Members
Posts: 33, Visits: 64
I understand what Peter has said, and that makes sense that the BO thinks it is dirty because of the difference in values between it and the database, depending on how you set the "Null option value" selected in the BO Mapper.

I now have data in every single column of the table, and all rows now set to not allow nulls.  I still get the same dirty BO when I navigate. 

A. I have set the BO to "Return Alternate on Null" on all columns and tried that as well.  Same result, can't navigate - causes dirty BO.

B. I have set the BO to "Return Alternate on Null / Set Alternate on Null" on all columns and tried that as well.  Same result, can't navigate - causes dirty BO.

This is how I understand the "Null option value" to work.....

Return Alternate on Null - If the DB column is null, it returns the alternate value to the BO AND updates the DB Column with the alternate value if one is not supplied otherwise.

Return and Set Alternate on Null - If the DB column is null, it returns the alternate value to the BO, but does NOT update the DB column with the alternate. i.e. it leaves the DB column alone unless a value is provided otherwise.

Both of these seems backwards to me.  i.e. Return and Set should return alt value to BO and Set value in DB.

It also seems like the whole idea of the BO Mapper with the Null option value, is to not have to write code to get around null values.  What am I missing here?

???????????????????

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
More than likely this is not a Null issue.  Put a breakpoint in the IsDirtyChanged event of the BO that is becoming dirty.  Then look at the call stack to see where it became dirty.  More than likely there is something on the form that is setting the field which is making it become dirty.  For example, a combo may be getting requeried or set again which updates the bound values which could be causing the BO to become dirty.  This is where I would start.  More than likely this is because of something that is occuring within the form outside of the framework.
Doug Birtell
Doug Birtell
StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)
Group: Forum Members
Posts: 33, Visits: 64
Brilliant!

Problem solved.  I knew it had to be something simple like that.

Thanks to all and have a wonderful weekend!

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
Great!  Glad you found the problem Smile 
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