CanSave bug?

CanSave bug?

Old forum URL: forums.lhotka.net/forums/t/9180.aspx


Ranjini posted on Wednesday, July 07, 2010

Tools : CSLA 4 beta 3 / Silverlight 4

I have a business base with several children , one being a BLB. In the UI, i have a tabbed child window representing different groupings of these children items. One of the tabs contains a DataGrid - DataForm (master-child) UI representing the BLB child object. Selecting one item in the grid, causes the dataform to populate , allowing the user the ability to change them. The entire childwindow has  a Save and Cancel button bound to CanSave and CanCancel of the viewmodel. When I change one of the items in the BLB , the save button becomes enabled. If i then proceed to save the object (thus making Save disabled again) and edit any of the other items, the Save never gets enabled again. However, if i Save and then tab away and come back to edit other items, the Save button gets enabled and everything works fine. I dont have any code here and everything is based on binding, so i am stumped as to what I can do to troubleshoot this, especially when it works on the first edit.

Any suggestions?

 

RockfordLhotka replied on Wednesday, July 07, 2010

Can you grab the current code from svn? I think I found and fixed this issue last week, but would like to be sure.

Ranjini replied on Thursday, July 08, 2010

Could you please give me a link to this version? I tried downloading but it seems like it is an older version. I dont want to make any assumptions here.

Thanks!

Ranjini

Ranjini replied on Tuesday, July 13, 2010

I moved to RC0 and am facing some newer problems. In my BO -> BLB structure i add objects to the BLB via the UI and that was working just fine before. Suddenly now, erratic errors are appearing when i do adds - http://docs.google.com/leaf?id=0B-Qwbn69ZX90MmEzYzdmN2YtN2NmZi00ZjE2LWJiMjYtMmMzYWRiZGY0MDM2&hl=en&authkey=CMin4pYK . Also, if you note in the snapshot, there is a dataform that has "autogeneratefields = true" and the "IsChild" property is appearing in it now, which i am sure wasnt before.. Please help with any suggestions!

Thanks

Ranjini

RockfordLhotka replied on Tuesday, July 13, 2010

The IsChild issue is a bug, so it will be fixed (I think the fix was checked in last night actually).

CSLA now enforces that a BusinessListBase can only contain child objects. This helps avoid bugs that would otherwise occur. Your code has a bug where the objects you are adding to the collection are not child objects.

Ranjini replied on Tuesday, July 13, 2010

As you note in the snapshot, the "IsChild" flag is true. Would there still be a chance I am not adding proper child objects?

Thanks for your quick response.

Peran replied on Tuesday, July 13, 2010

Hi,

 

Your first issue is a result of this change:

http://www.lhotka.net/cslabugs/edit_bug.aspx?id=25

You need to call MarkChild() on your business object before inserting it into your list, or use the DataPortal.CreateChild() which call this on your behalf.

 

The dataform issue will be fixed by this:

http://www.lhotka.net/cslabugs/edit_bug.aspx?id=797

Updated code is in SVN.

 

Regards

 

Peran

Ranjini replied on Tuesday, July 13, 2010

Per the link - http://www.lhotka.net/cslabugs/edit_bug.aspx?id=25 , the exception is thrown if IsCHild is false, which doesnt seem to be the case in my situation as you can see from the snapshot.  Am i still doing something wrong?  I am using AddNew() ( eg. Model.MyBusinessListBase.AddNew() is the code in my viewmodel) to add my child object and not overriding any of the default create behaviour. In other words, I am letting the DataPortal add the child to the collection and thus expect the MarkAsChild to be called automatically.

Peran replied on Tuesday, July 13, 2010

There is something not quite adding up here; your UI is showing IsChild = true, yet when your code reaches BLB.InsertItem IsChild = false. 

I can't replicate the issue using BLB.AddNew() in unit tests, please could you add a break point on BLB.AddNewCore; DataPortal.CreateChild<C>() should create an item with IsChild = true. Try adding a break point to BLB.InsertItem(), item.IsChild will = false for the exception to occur, does the stacktrace help?

Ranjini replied on Tuesday, July 13, 2010

Thank you all for helping me debug this.. You were right about the IsChild being false.

It turned out that the child object causing the error was different from the one I thought was the culprit. In that specific object I used an AddNew but later in my code, it was being replaced by a new child instance and that was causing the error. Thanks again for helping me through this and I apologize for any unnecessary confusions !

 

Copyright (c) Marimer LLC