New Posts New Posts RSS Feed: Preset Trigger Handling
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Preset Trigger Handling

 Post Reply Post Reply
Author
toddb View Drop Down
Newbie
Newbie
Avatar

Joined: 04-Feb-2009
Location: Australia
Posts: 8
Post Options Post Options   Quote toddb Quote  Post ReplyReply Direct Link To This Post Topic: Preset Trigger Handling
    Posted: 04-Feb-2009 at 8:02pm
Hi,
 
Am fairly new to IdeaBlade (and VB .NET) so I hope this is an easy one...
 
I have added a Preset verfication rule to one of my entities that checks whether or not the value is unique. If a duplicate entry is entered via the UI it automtically fires the verifier as expected but I would like to override the default behaviour so that instead of the Error bullet appearing, a window pops up in its place indicating the entry is a duplicate and giving the user the option to navigate to that particular entity. So, what I am wondering is:
 
1. What is the best way to prevent the error bullets coming up?
2. Where / how do I get hold of the verification results?
 
Thanks for any help anyone can provide,
Todd
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: 05-Feb-2009 at 3:17pm
It may be a bit tricky to have a pop-up window appear every time an invalid value is entered on the form. Also I can see a potential for this to become quite bothersome if this behavior occurs on multiple properties on the same form.
 
An alternative to this type of error reporting may be to leave the error bullet next to the invalid field, giving the user the option to fix right away or move off the field and continue editing the rest of the form. Then when the user tries to leave the form or upon saving, perform an instance verification on the entity, and display the results in a frame at the bottom of the form. There is a Verification tutorial available under Intermediate Topics (see Pt5 of the 5 solutions) demonstrating this.
 
If this doesn't help your specific case, the tutorial will show you how you can collect the verification results in answer to #2.
 
If you are intent on preventing the error bullets from displaying, there is a forum post: http://www.ideablade.com/forum/forum_posts.asp?TID=120 with sample C# code that shows you how to turn the bullets off (scroll mid-way down).
Back to Top
toddb View Drop Down
Newbie
Newbie
Avatar

Joined: 04-Feb-2009
Location: Australia
Posts: 8
Post Options Post Options   Quote toddb Quote  Post ReplyReply Direct Link To This Post Posted: 05-Feb-2009 at 4:12pm
Hi Eileen,
 
Thanks for your reply. I only want the window to pop up for one field in the form and the purpose is so that the user doesn't waste time entering a whole heap of data if that record already exists elsewhere. I could just leave the error bullet saying "Hey, this record looks like it exists elsewhere how about you go and find it" but I would prefer to give them the option of having our application do the work for them. Make sense?
 
I have had a look at the Instance verification tutorial and it makes sense. I would still like to know how I can access the same kind of verifier results from within my form after a pre or postset trigger has fired. Is this possible?
 
I was thinking that I might be able to call the VerifierEngine.Execute method from within the Validating event of the control but I am not sure how to setup the parameters to simulate the Preset trigger...
 
Sorry if my description of what I am trying to do is not clear.
 
Thanks for the link on removing the bullets I'll check it out!
 
Kind regards,
Todd.
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: 05-Feb-2009 at 5:13pm

Ok... first a little background information on how the verification is executed based on a trigger or setting of a property.

If you take a look at the generated code (xxxDataRow class) for a property, in the setter you will see the following:
 
    public virtual System.String LastName {
      get {
        System.String result_;
        if (GetInterceptor<System.String>("LastName", GetLastNameImpl, out result_)) return result_;
        return GetLastNameImpl();
      }
      [System.Diagnostics.DebuggerNonUserCode]
      set {
        if (BeforeSetValue("LastName", value)) {
          if (!SetInterceptor<System.String>("LastName", value, SetLastNameImpl)) {
            SetLastNameImpl(value);
          } 
        AfterSetValue("LastName");
      }
      }   
    }
 
It is the base implementation of the BeforeSetValue (preset) and AfterSetValue (postset) methods that makes a call to the VerifierEngine. Here is the code for BeforeSetValue:
 
    /// <summary>
    /// Override this method to perform any logic before a column value is set.  Make sure to
    /// call the base implementation if you want any registered preset verifiers to execute.
    /// </summary>
    /// <param name="pPropertyName"></param>
    /// <param name="pProposedValue"></param>
    /// <returns></returns>
    protected virtual bool BeforeSetValue(string pPropertyName, Object pProposedValue) {
      VerifierResultCollection results = this.VerifierEngine.Execute(this, pPropertyName, pProposedValue);
      if (!results.AreOk) {
        throw new VerifierResultException(results);
      }
      return true;
    }
 
You can override the above method in your entity class and, for that particular property, not throw an exception but cache the results instead. At this point your entity class would have the verification results.


Edited by eileenv - 05-Feb-2009 at 5:15pm
Back to Top
toddb View Drop Down
Newbie
Newbie
Avatar

Joined: 04-Feb-2009
Location: Australia
Posts: 8
Post Options Post Options   Quote toddb Quote  Post ReplyReply Direct Link To This Post Posted: 05-Feb-2009 at 8:53pm

Thanks Eileen. I'll play around with that idea and see if I can get what I want going. Now that I think about it a little more, I suspect I actually need to still throw the error and then tap into the ErrorProvider handler in order to do something different with the results :)

Kind regards,
Todd.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down