I cleaned up my hibernate-validator/wicket integration code, and put it along with an example in my public svn repository. I describe the integration and the example here:
http://42lines.net/content/integrating-hibernate-validator-and-wicket If people care to leave feedback, please do. In particular I'm interested in whether it's worth contributing it to wicketstuff. -Clint 2009/5/19 Dorothée Giernoth <dorothee.giern...@kds-kg.de>: > > > I would find this very useful! So a contribution to wicket-stuff would be > awesome. Thnx. > > - dg > > -----Ursprüngliche Nachricht----- > Von: Clint Popetz [mailto:cl...@42lines.net] > Gesendet: Dienstag, 19. Mai 2009 13:49 > An: users@wicket.apache.org > Betreff: Re: How to validate unique constraint? > > It's relatively straightforward to use the hibernate validator api to > apply JPA constraints: > > import org.hibernate.validator.*; > InvalidValue[] invalidValues = new > ClassValidator(MyModel.class).getInvalidValues(instanceOfMyModel); > > This can also be done per-property; see the javadocs. > > I've done this locally; if folks would find it useful I'll contribute > it to wicketstuff. > > -Clint > > On Tue, May 19, 2009 at 2:15 AM, Christian Helmbold > <christian.helmb...@yahoo.de> wrote: >> >> How can I validate a unique constraint with Wicket? Because only the value >> of an input field is passed to onValidate(IValidatable validatable), there >> is no chance to check if this value belongs to a specific object to update >> or if it would violate a unique constraint when creating a new object. >> onValidate would need another paremeter for the related object. >> >> I see two possibilities: >> >> a) Use a form validator and get the related model object from the form. >> >> b) Pass the related object to the constructor of the Validator. I'm not >> sure, if the validator would be recreated any time the model object changes. >> >> I would prefer a validator tied to the field and not to the form, because >> that would be more intuitive. >> >> Another idea is to use existing JPA annotations. @Column(unique=true) is >> already there but not used for validation (outside the database). Perhaps >> there is a way to use this annotation. I really like the domain level >> validation of Grails: http://grails.org/doc/1.1/guide/7.%20Validation.html >> >> How would you validate a unique constraint with wicket? >> >> Thanks in advance >> Christian >> >> >> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org >> For additional commands, e-mail: users-h...@wicket.apache.org >> >> > > > > -- > Clint Popetz > http://42lines.net > Scalable Web Application Development > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > > -- Clint Popetz http://42lines.net Scalable Web Application Development --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org