Re: Cayenne Annotations

From: Damir Bijuklic (damirbijukli..ahoo.com)
Date: Sat Jan 13 2007 - 04:26:00 EST

  • Next message: Andrus Adamchik: "Re: Cayenne Annotations"

    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 <websystem..mail.com> To: cayenne-user@incubator.apache.org 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 <andru..bjectstyle.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: > >..mail > > @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 > > ..pperCase > > 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 > > ___________________________________________________________ The all-new Yahoo! Mail goes wherever you go - free your email address from your Internet provider. http://uk.docs.yahoo.com/nowyoucan.html



    This archive was generated by hypermail 2.0.0 : Sat Jan 13 2007 - 04:26:35 EST