Hi Damir, Steve --

It would be nice if this was included into cayenne 3 release, maybe you should contact Andrus about that.

I am here of course, and this (or the dev) list is the best place to discuss inclusion of any code in Cayenne.

Quick glance at the code shows that the Cayenne integration-specific piece is the Velocity template. The rest is rather generic (is there a Tapestry specific piece?).

The main nuisance as Steve mentioned is the requirement to override getters to add validations not derived from existing Cayenne. This can be addressed via generic properties when CAY-400 is implemented (it has been delayed, but not forgotten)

http://issues.apache.org/cayenne/browse/CAY-400

So if there is a desire to see this in Cayenne, IMO the best place to start is to help with CAY-400, and then come back to this discussion of maybe making it a separate Cayenne module.

What do you think?

Andrus



On Jan 13, 2007, at 12:26 PM, Damir Bijuklic wrote:
Hi Steve,

I think your work could be really useful for rapid prototyping webapps with BeanForm. Unfortuanltely, my schedule this month is very tight so i won't be able to play with.

It would be nice if this was included into cayenne 3 release, maybe you should contact Andrus about that.

Damir

----- Original Message ----
From: Steve Wells <[EMAIL PROTECTED]>
To: [email protected]
Sent: Friday, 12 January, 2007 4:59:46 AM
Subject: Re: Cayenne Annotations

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 <[EMAIL PROTECTED]> 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

Reply via email to