Re: Validation, ValidateForInsert, ValidationResult

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Wed Mar 09 2005 - 09:35:57 EST

  • Next message: Andrus Adamchik: "Re: Cayenne modeler - need to generate setters and getters for primary key"

    > Hi Could someone explain how to use the Validate method?
    > And how do I use the ValidationResult object?
    >
    > Do I just create an empty ValidationResult and pass it to the validate
    > method? How do I use it if there are validation errors? Do I obtain it
    > from the context in the Error page?
    >
    > Thanks!
    >
    > Fredrik

    Hi Fredrik,

    A few points on vaidation:

    * You simply override validate* methods as shown here -
    http://objectstyle.org/cayenne/userguide/dataobjects/validation.html

    * You neither create ValidationResult, nor call those methods directly.
    Cayenne creates it for you and invokes appropriate validate* inside
    DataContext.commitChanges().

    * To process validation failures, you wrap commitChanges() in try/catch
    and catch ValidationException that will contain ValidationResult.

    Andrus



    This archive was generated by hypermail 2.0.0 : Wed Mar 09 2005 - 09:35:58 EST