New Posts New Posts RSS Feed: Not using the Error provider?
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Not using the Error provider?

 Post Reply Post Reply
Author
Matthew View Drop Down
Newbie
Newbie


Joined: 31-Jul-2007
Posts: 14
Post Options Post Options   Quote Matthew Quote  Post ReplyReply Direct Link To This Post Topic: Not using the Error provider?
    Posted: 06-Sep-2007 at 9:41am
I am playing around with the Verification part of DevForce and was wondering if anyone can give me some pointers.

In some of our apps, we may want to use the Error provider method of displaying errors, but in many we will not.  One different scenario I am looking at now is something like this:

The user type an incorrect date in a date field and hits Tab to move to the next field.  The proposed value fails verification but the focus is allowed to move to the next field.  The backcolor of the (incorrect) date field is changed to red (or the text is changed to red, etc).

I can kind of see how to do this if I was validating the whole object, but not using a Preset or postset trigger.  It appears that an exception is being thrown somewhere when the preset rule fails, and then the UI catches it to display with the error provider, but I don't see how I can get to that exception before the UI/binding does.

Has anyone worked through this that might be able to give me a point in the right direction?

Thanks,
Matt
Back to Top
Matthew View Drop Down
Newbie
Newbie


Joined: 31-Jul-2007
Posts: 14
Post Options Post Options   Quote Matthew Quote  Post ReplyReply Direct Link To This Post Posted: 06-Sep-2007 at 2:29pm
Ok, so I see that attaching a Handler to the ControlBindingManager Descriptor Error event is the way to make the UI change I'm looking for, but I'm still struggling with one thing.

I assume at some point the Verifier is run on a Preset or Postset basis, and a VerifierResult is created that is at some point translated into the Exception that is thrown.  I can't quite figure out how to get at the actual VerifierResult.  I would like to see if it is considered a warning or not, and make a UI change based on that. 
Back to Top
eileenv View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 15-Jun-2007
Location: United States
Posts: 68
Post Options Post Options   Quote eileenv Quote  Post ReplyReply Direct Link To This Post Posted: 06-Sep-2007 at 3:17pm
There are BeforeSetValue and AfterSetValue methods that are generated into each Setter in the DataRow class (granted you turned Verification "on" w/ default options in the OM). The base implementation of these methods calls VerifierEngine.Execute, returns a VerifierResultCollection, and throws an exception if one of the verifier results is an error. In the general case, you can override this behavior to iterate through the verifier results, and do something. Alternatively, you can override a specific property's set method and handle the exception that gets thrown by the base set method.
Back to Top
Matthew View Drop Down
Newbie
Newbie


Joined: 31-Jul-2007
Posts: 14
Post Options Post Options   Quote Matthew Quote  Post ReplyReply Direct Link To This Post Posted: 08-Sep-2007 at 11:15am
Thanks so much, that was the direction I needed and I think I see how to accomplish what I want now.

Part of my struggle is to change my idea of what verification actually is.  In our app, there is a lot of "rules" that are really warnings, not a hard yes/no answer.  Currently all these rules are mixed together, and I think using DevForce, those two types really need to be separate.  The warning rules have very far reaching UI responses, while the pass/fail rules generally are "show the error message, make them correct it before save" type responses.
Back to Top
eileenv View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 15-Jun-2007
Location: United States
Posts: 68
Post Options Post Options   Quote eileenv Quote  Post ReplyReply Direct Link To This Post Posted: 10-Sep-2007 at 2:12pm
One thing to emphasize is that, in the case of a Warning, an exception will not be thrown by the VerifierEngine. A warning is still considered "OK" and will pass the check. The warning will still be captured and returned via the VerificationResultsCollection. There are various properties and methods you can invoke on the collection class to retrieve the exact information you need. Hope this helps.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down