Re: Automated Validation of Attributes

From: Michael Gentry (mgentr..asslight.net)
Date: Wed Mar 10 2010 - 14:07:44 EST

  • Next message: Andrey Razumovsky: "Re: When can we expect Cayenne 3.0 final?"

    Well, without going into a great deal of explanation of T5 and
    validation, the onValidateFromFirstName() method gets called on the T5
    controller class for the web page/component before you'd ever call
    dataContext.commitChanges() -- which is when the Cayenne validation
    occurs. If using T5 with Cayenne I'd probably opt to let Cayenne do
    the validation and implement validateForSave() or maybe use the new
    lifecycle callbacks (such as PrePersist) and let T5 catch any
    exceptions to report them to the user.

    mrg

    On Wed, Mar 10, 2010 at 1:38 PM, Andrew Lindesay <ap..indesay.co.nz> wrote:
    > I'm just waking up too!
    >
    > You are right, it is somewhat "web framework" dependent; if you are using Tapestry-5 then, does the 'onValidateFromFirstName' get invoked from the 'validateForSave' in the data objects somehow as well or do you need to handle single-attribute validation manually from that point?
    >
    > Regards;
    >
    >> Part of this would depend on your UI, too.  If you are using Tapestry
    >> 5, for example, it has similar validation built in.  Say you have a
    >> text field with an id=firstName, T5 will invoke (if present)
    >> onValidateFromFirstName(String newFirstName) for you before ever
    >> calling the setter.  If you throw an exception out of that, T5 will
    >> know not to call the setter.  Once you've gone past that logic (which
    >> would be the case you mention) it is a bit too late ...
    >
    > ___
    > Andrew Lindesay
    > www.lindesay.co.nz
    >
    >



    This archive was generated by hypermail 2.0.0 : Wed Mar 10 2010 - 14:09:47 EST