New Posts New Posts RSS Feed: validation on xxx.create method
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

validation on xxx.create method

 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: validation on xxx.create method
    Posted: 29-Feb-2008 at 4:09pm
What's the best practice for handling required fields when doing a Create on an object.
When I try entering in a new line it automatically shows the errorprovider saying that the value is invalid.

The example that you have in the tutorial makes it easy because the two required fields in the order summary table CustomerID and EmployeeID are not required fields in the table.  My SQL table has 2 key fields that are required.
 
Thanks
 
 
 

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-Mar-2008 at 10:37am

How to handle required fields when doing a Create on an object depends on what you want your users to experience. I'm assuming you generated your business objects with Verification turned "on" and its sub-option to generate verifiers. The "Generate predefined verifiers" options means (in effect) that you want DevForce to inscribe "Required" verifiers for every non-null property it generates.

The verifiers are generated with Preset triggers, which means they lock up the UI when the user sets the value to null (more precisely, they throw an exception which causes Data Binding to lock up the UI).
 
This is appropriate most of the time and is the safest thing to do. That is, it is safest to assume that the user should not be able to leave a required field blank once she has started entering data into it.
 
However if you decide that it is OK to allow blank strings temporarily (you should run Verification before the save to catch errors), there are a couple options you can do:
 
  1. You could turn off auto-generation of verifiers (but leave generation of BeforeSetValue and AfterSetValue) and add the verifiers you want in the business logic of the entity.
 
  2. Alternatively, you can programmatically discover the generated required verifiers and change the triggering from Preset to Postset. Postset means the verifier is evaluated after the property is set (no exception is thrown and the user can move out of the control).
 
Hope this helps.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down