New Posts New Posts RSS Feed: Integer values being 0
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Integer values being 0

 Post Reply Post Reply
Author
DataMan View Drop Down
Groupie
Groupie
Avatar

Joined: 26-Jul-2007
Location: Canada
Posts: 52
Post Options Post Options   Quote DataMan Quote  Post ReplyReply Direct Link To This Post Topic: Integer values being 0
    Posted: 22-Apr-2008 at 8:45am

I have a form with a textbox on it (added using devforce) that is tied to an integer field in SQL.

I added a verifier to the field that this textbox is bound to which says that the value is required and the min value is 1.

 
When I add a new record using the create method, the value 0 automatically gets entered into the text box.  If I don’t change that value or tab into the field I am allowed to save the record even though it is 0.  No error message occurs.

 

The same thing is happening with all of my comboboxes that are tied to integer values.

 

Do I need to add my own validation of those text boxes(!=0)/comboboxes(notinlist) and throw an error of my own or is there a way to do it in Ideablade?

 
Thanks
Back to Top
davidklitzke View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 14-Jun-2007
Posts: 715
Post Options Post Options   Quote davidklitzke Quote  Post ReplyReply Direct Link To This Post Posted: 22-Apr-2008 at 7:49pm
Creating a new entity is one place where some of the properties of a business object can escape verification.  If a property is a required property, it must be initialized in the process of creation.  Furthermore, if it is an integer field, it will be initialized to zero.
 
There are at least two solutions/workarounds to this problem.
 
(1) In the creation code, make sure there are no uninitialized fields that would break verification rules if set to the default value (e.g., an integer field set to 0).  This is the quick (but by no means foolproof) method.
 
(2) Use Instance Verification immediately after creating a business object.  This is the sure way (although it is a little more work).  Read more about Instance Verification in the "Developer's Guide".


Edited by davidklitzke - 22-Apr-2008 at 7:54pm
Back to Top
DataMan View Drop Down
Groupie
Groupie
Avatar

Joined: 26-Jul-2007
Location: Canada
Posts: 52
Post Options Post Options   Quote DataMan Quote  Post ReplyReply Direct Link To This Post Posted: 25-Apr-2008 at 10:01am
Number 1 is an interesting idea because then if what you set in code for the value to be isn't what the user wants they will change it.
 
Number 2 - I've looked into this and while it works really well I was assuming that when i called the instance verification that it would turn on the ErrorProvider on the form for the field that failed.  Without me doing some research and taking the easy way out by asking you :-) Is there any way to, upon verification, get the errorproviders flashing for items that don't validate?
 
Thanks
 
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down