StrataFrame Forum

Browse Dialogue Problem

http://forum.strataframe.net/Topic1312.aspx

By Wayne Van Rooyen - 5/31/2006

When setting up a browse dialogue and a record is returned, select the record and click okay. This takes you to the maintenance window with the selected record active. However if you now movenext etc on the one pk field update the rest of the test boxes stay as is. Did i do something wrong or is this a bug.
By StrataFrame Team - 6/1/2006

Is this the functionality you're getting in the sample, or is this one of your applications?  And are you using a standard maintenance form, or the DevExpress maintenance form?  When you select the record from the browse and return to the calling form, all of the records returned from the browse will be returned to the dataset, and the current record will be selected.  So, yes, when you navigate after a browse, the rest of the fields should be updating.
By Wayne Van Rooyen - 6/1/2006

HI,

I was using the Standard maintenance form, i followed the tutorial from the help file. I dont see a tutorial in vb that conforms to the step by step in the help manual so i cant test it against my example. I will start again and see if i can reproduce it.

PS: The Full sample provided in vb called "StrataFrameSample.sln" Click Customer Maintenenance then "Browse" then "Search" and double click on a returned record. Produces error

System.InvalidCastException was unhandled by user code
  Message="Specified cast is not valid."
  Source="StrataFrameSample"
  StackTrace:
       at StrataFrameSample.CustomersBO.get_cust_phonedaytype() in C:\Program Files\MicroFour\StrataFrame\VB.NET Samples\WinForms Sample\StrataFrameSample\Business Objects\CustomersBO.Designer.vb:line 548
       at StrataFrameSample.CustomersBO.Field_cust_phonedaytype_Descriptor.GetValue(Object component) in C:\Program Files\MicroFour\StrataFrame\VB.NET Samples\WinForms Sample\StrataFrameSample\Business Objects\CustomersBO.Designer.vb:line 1291
       at System.Windows.Forms.BindToObject.GetValue()
       at System.Windows.Forms.Binding.PushData(Boolean force)

Regards Wayne

By StrataFrame Team - 6/1/2006

Yes, I just fixed that problem... it will be corrected in the next update.

As for the problem of the controls not refreshing when the business object is navigated, if you can reproduce it, let me know, and ZIP your solution and post it here on the forum.

By Larry Caylor - 6/2/2006

I having a similar problem; getting an InvalidCastException using version 1.41. I have a standard SF maint. form. On the form I have two controls, a textbox and combo box. The combo box is populated by an enumeration and is bound to the BO. The text box is bound to a string property on the BO. If I open the maintenance form and click on “New” I can add a new record with no error. However if I click on browse, retrieve some records and then click “New” I get the InvalidCastException. If I unbind the combo box from the BO everything works fine.

-Larry

 

By StrataFrame Team - 6/2/2006

You get the InvalidCastException when the combo box is populated using an enumeration and the bound field property on the business object is not typed as the same enumeration. 

When you use an enumeration to populate a combobox, the SelectedValue (which is what the combobox will bind to by default) actually contains enumeration values, not integer values.  So, to bind to that combobox, you'll need to go to the BOMapper and customize the field to return the enumeration value rather than an integer. 

If you don't want to customize the field, you'll have to populate the combo manually, or it will continue to throw the InvalidCastException Sad

By Larry Caylor - 6/2/2006

The field has been customized to the enumeration type in object mapper. I think something else is going on. Also attached is a screen shot from OM that I get when I do a "Rebuild All" after customizing one BO. What does the warning mean?

-Larry

By StrataFrame Team - 6/2/2006

The warning means that you have one or more fields that have been customized on the business object that have been "removed" from the business object meaning this:

1) MyBO's SQL table has a field called "field1"

2) You customize "field1" to, say, trim the value.

3) You change the structure of the SQL table so that "field1" no longer exists (or was renamed).

4) The BOMapper thinks the field disappeared, but the customization record still exists within the BOMapper.

So, the warning is just telling you that not all of the fields that you customized are being created on the business object.

As for your other error, can you post the red error message that contains the stack trace... might tell us where that exception is being thrown from Smile

By Larry Caylor - 6/2/2006

Ben,

 

Thanks for the explanation of the warning message. I’ve attached a couple of screen shots. The two field sample I’m using is a stripped down sample of a more complex object. While that form includes an enum bound combo box it was a string property that was getting the same error.  In stepping through the code I noticed that when “New” was clicked without first doing a browse, any fields that were not set to allow null in OM were automatically set to default non-NULL values. When a Browse was done and rows retrieved prior to clicking on “New’ the fields in the BO were not automatically set to defaults.

 

-Larry

By StrataFrame Team - 6/2/2006

Oh, the infamous DBNull.Value...  basically, you're getting that during the Get of your property (just like your screenshot says).  The DBNull is a special object type that is used to represent a NULL value in the database.  If a field can contain null values, then you'll need to configure that field through the BOMapper to either "Return Alternate On Null" or "Use Nullable Generic" (the generic can only be used with value types (no strings)).  Your best bet would be to either return "Nothing" or "String.Empty" on a null value.  That will fix your problem. 
By Larry Caylor - 6/2/2006

Ben,

Correct me if I'm wrong but I was under the impression that the OM alternate values for null was to eliminate problems where NULL data was returned from the database. In this case I'm adding a new row. Since I don't have the source for 1.41 I'm not able to step through all of the code but what I've noticed is that in the cases where I'm receiving the errors is that fileds that would automatically be set to a non null value (even if they were not configured to do so in OM) for a new row are not being set.

-Larry

By StrataFrame Team - 6/2/2006

Check the "AllowNullValues" property on the business object and make sure it's False.  If that property is set to True, then the business object will not initialize the values within a new row.
By Larry Caylor - 6/2/2006

Ben.

On both my test BO and the actual application I'm coding the AllowNullValueOnNewRow on the BO is set to False. If it helps, when receiving this error the BO's set-default-values code never gets executed. It fails right after retrieving the BO's FieldDbTypes.

-Larry

By Larry Caylor - 6/3/2006

Ben,

Whatever is causing the problem appears to have been introduced in v1.41. I moved the code back to version 1.4 and everything works as expected.

-Larry

By StrataFrame Team - 6/3/2006

Hehe, I was just replying Larry Smile 

When you get the exception in your program, and the .NET unhandled exception dialog pops up, press "Continue" on your debug and you should get the red "Application Error" window that will have a complete list of the exceptions and inner exceptions and the stack traces of all of the exceptions concatenated together.  That should give me a clue where it's coming from.  You can copy/paste the content of that window and post it here.

By Larry Caylor - 6/3/2006

Ben,

It took me a few minutes to get back to you since I had to re-install v1.41.

Continuing just brings up the same error for the next field and so on. Once I've cycled through all the fields the maint form is displayed and I'm able to enter the data and save the record.

-Larry

By StrataFrame Team - 6/4/2006

When it gives you that error for each field, do you get the red error window?  I'm wondering if the stack trace within that error window contains a call to "CurrencyManager.ListChanged" or "CurrencyManager.OnListChanged."  .NET might be trying to do something when the internal DataTable changes rather than waiting for the row to be initialized.
By Larry Caylor - 6/5/2006

Ben,

A red error window is never displayed. Attached is a screen shot with the stack trace associated with the error.

-Larry

By StrataFrame Team - 6/5/2006

I think I figured it out, Larry, the ListChanged event is being fired too soon (before the record has actually been initialized).  I'm working on a fix right now.
By Larry Caylor - 6/7/2006

Ben,

Any estimate of when a fix will be available? If it's going to be awhile I'll go back to v1.4

-Larry

By StrataFrame Team - 6/8/2006

I have it fixed, Larry, and I should have the update available around the time that you get into the office (in a couple of hours).
By Larry Caylor - 6/8/2006

Ben,

That fixed the problemSmile  Thanks for the quick response.

-Larry

By StrataFrame Team - 6/8/2006

No problem.