Validators and IDataErrorInfo

Posts   
 
    
ElQueso avatar
ElQueso
User
Posts: 27
Joined: 08-Oct-2005
# Posted on: 08-Oct-2005 23:21:14   

This is actually my first post on the forums - I haven't been using GenPro all that long, so hopefully this isn't some easy answer that I just missed wink

I'm providing custom field- and entity-level validators to my entities. They work really well, and I'm very pleased with how easy it is to implement these.

I just have one question - I'm not sure how to go about implementing the IDataErrorInfo interface. It's not a necessity, but it does provide a good means for entity-to-interface communication.

In particular, I have a grid that I am binding an EntityCollection to. Each of my entities have a custom validator for boths levels of validation. For my example, If I have a validation issue at the field level, the validator returns false properly. The grid, however, simply reverts back to the previous value when I tab out due to the validation error. It would be nicer if there was some means of telling the user what occurred and why. I'm sure I could probably hook into my grid's validation routines or something, but I was hoping there was some way to do this with my data entities.

The grid I am using works with the .NET framework's IDataErrorInfo interface to provide information to the user as to what validation issues were found. I don't see that GenPro implements that interface anywhere.

The only way I could see at this point to do it would be to modify the GenPro templates to put this in. Any thoughts on this?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 10-Oct-2005 08:58:06   

The interface isn't implemented because the amount of gui-related elements in the classes has been kept as low as possible.

I'm not sure what you're using: selfservicing or adapter. For adapter, you can replace the entityCollectionAdapter.template with an altered version which implements the interface, for selfservicing you can add the interface to the usercode region in the generated classes. Though, it's a bit difficult to communicate with the collection from the EntityValidator objects, as they don't receive a reference to that collection... IMHO the best way to communicate an error to the user is to throw an exception in your validator and catch it in the GUI class, which then shows detailed info to the user or alters some screen element.

Frans Bouma | Lead developer LLBLGen Pro
can1
User
Posts: 77
Joined: 16-Sep-2005
# Posted on: 06-Nov-2005 01:47:29   

Deleted by Can1, will start a new thread.