Playing with CSLA 4 preview. Just a small WPF test application.
Right now the behavior of DoRefresh is to catch any DataPortal exception and set the Error property on the ViewModel.
In many (if not all) scenarios, I want to "blank out" all bound controls in such situation, so I'd set Model = null. I wonder if that shouldn't be DoRefresh's default behavior ? I'd like to hear the pros and cons of the actual vs. proposed behavior.
My POV is that if a call to DoRefresh fails, I certainly don't want to leave the controls displaying the old object's data. For example, if I call DoRefresh("GetCustomer", ID); and the ID is not a valid one, then of course no object will be returned from the DataPortal.
Thanks for sharing your ideas.
I was seeing it going near the bottom ;-)
OnError() is a virtual method, so you can override OnError() and set Model to null.
This is one of those things where I could make the behavior work either way to make some subset of users happy. But if I set Model to null, it is harder for someone to block that behavior than if I leave Model alone - because it is easy to override OnError() and make it null.
I think you're right on this. That's why I wanted to "test the water".
Overriding OnError sounds like a good way to handle this situation.
Maybe my question has a broader scope than what I suspect ? I mean, how a "no data" situation should be handled is certainly different from app to app. In my case, as I said, I blank out the controls (through databinding). Others might have different techniques ?
Copyright (c) Marimer LLC