cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steve Wells" <websyst...@gmail.com>
Subject Re: Cayenne Annotations
Date Fri, 12 Jan 2007 03:59:46 GMT
Well it seems to have been working ok for me so far.

I thought I'd release it:
http://sourceforge.net/projects/cayannotations/

I'll put it on the maven repository on ibiblio if there is any demand.
Until then maven users will have to manually install it in their repos.

Any feedback appreciated.

Cheers,

Steve


On 09/01/07, Andrus Adamchik <andrus@objectstyle.org> wrote:
>
> > So what do people think of this approach?
>
> Nice if you can do it in one place. If you want Cayenne only to
> supply extra metadata, but Tapestry do the validation, you can turn
> off Cayenne validation by unchecking "object validation" checkbox in
> the DataDomain panel in the Modeler.
>
> Cheers,
> Andrus
>
>
> On Jan 7, 2007, at 9:27 AM, Steve Wells wrote:
>
> > I've started working on a package of cayenne annotations, so far
> > only for
> > validations.  My initial motivation was from using the Tapestry
> > bean-form
> > component.  Bean-form will create a Html form for you including
> > validations
> > dynamically based on a Bean passed to it.  There are a lot of
> > customisations
> > that can be done.  It can save a lot of time, effort, errors.
> >
> > What was annoying me was that you had to repeat your validations with
> > Cayenne DataObjects.  1. in the Cayenne model and 2 with the
> > beanform.  This
> > was an obvious signal that something had to be done, it wasn't
> > DRY.  What
> > I've come up with so far to solve this:
> > 1. A modified Cayenne super class Velocity template to generate
> > Cayenne
> > Annotations.  Generates Required and Length annotations
> > 2. An annotations package based on OVal.  includes Min, Max,
> > Required, Past,
> > Future, RegEx, Email, Length and whatever else you can dream up.
> > 3. A bean-form Cayenne integrator.
> >
> > All the user cares about then is practically very little.  Bean-
> > form grabs
> > the Cayenne generated annotation and generates the Tapestry
> > validator for
> > them.
> >
> > You can also add in annotations that can't be guessed from your data
> > model into your subclass, just override the superclass eg:
> > @Email
> > @Required
> > public String getEmail() {
> >   return super.getEmail;
> > }
> >
> > Next step is when we want to add a validation that none of the
> > frameworks
> > support (maybe you have a rich client etc), this is where OVal
> > really comes
> > into it, eg:
> >
> > Cayenne sub-class:
> >   // Must be uppercase
> >   @UpperCase
> >   public String getUpperCaseField() {
> >      return  upperCaseField;
> >   }
> >
> > Validation layer, eg Tapestry page class:
> >       Validator validator = new CayenneValidator();
> >
> >        // collect the violated constraints
> >        List<ConstraintViolation> violations = validator.validate
> > (myObjEntity);
> >        if (violations.size() > 0) // tell the user what is wrong from
> > annotation generated message, field must be upper case etc;
> > So what do people think of this approach?
> >
> >
> > Cheers,
> >
> > Steve
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message