cayenne-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Gentry <>
Subject Re: Automated Validation of Attributes
Date Wed, 10 Mar 2010 19:07:44 GMT
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.


On Wed, Mar 10, 2010 at 1:38 PM, Andrew Lindesay <> 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

View raw message