You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Ophélie Salm <op...@zenika.com> on 2010/01/12 14:51:05 UTC

JSR 303 Wicket integration

Hi all,

I'm Ophélie @ Zenika !

As the subject states, i've got a few questions regarding the JSR 303 (bean validation) integration with wicket. That's something a lot of people at Zenika are eager to see evolving from the current "yes, it'd be great!" project to a real concrete one. I know it's part of the wicket 1.5 wishlist too, so i assume you might be interested as well ;)

To be fair, this idea came up with this blog post : http://magnus-k-karlsson.blogspot.com/2009/10/integrate-jsr-303-bean-validation-and.html
but what we really want first, is to make bean validation available as a form Behavior. Although it's still an open discussion.

As i was searching the nabble archive, i noticed that the same subject came up regularly, but i can't seem to find an ongoing project. However, i stumbled upon the wicketstuff-hibernate-behavior made by Ryan Sonnek, which is based on the Hibernate Validator framework. Unfortunately, this project has moved to the attic due to lack of updates. So i was thinking about starting over with this as a base project or inspiration, then to make it fully compatible with wicket 1.4.x and of course the JSR 303.

I know some people already did some blog posts, sharing their own code as an answer to the JSR 303 integration, but what we want here, is to make it available to a wider audience of wicket users, say, as a wicket stuff component first and, why not, as part of wicket core later on.

So, before starting anything, i need to know if someone is already taking charge of a similar project ? If not, we're ready to dig into this matter here at Zenika. So let me hear some feedback about this idea, what do you think ?

Regards.
--
Ophélie Salm
Zenika
http://www.zenika.com
http://blog.zenika.com
http://yeswicket.com

Re: JSR 303 Wicket integration

Posted by Ophélie Salm <op...@zenika.com>.
Hi all,

As promised, here is our attempt at providing a JSR-303 (Bean 
Validation) integration to Wicket. The source is for the moment stored 
on GoogleCode:
   http://code.google.com/p/wicket-jsr303-validators/

It comes with unit tests that cover all the situations we thought about, 
and a very basic sample.

It consists of two validators which can be added either on a form
component for single field validation, or on a form as a whole to
validate all of its children components.

You can find the project announcement at our blog here:
   http://blog.zenika.com

Our final goal would be to contribute the code if it is deemed worthy. 
Maybe in Wicket Stuff or directly in the core if there's interest? 
Please let us know what you think of it, either by mail or using the 
GoogleCode issue tracker.

Cheers!

--
Ophélie Salm
Zenika
http://zenika.com
http://blog.zenika.com
http://yeswicket.com

Re: JSR 303 Wicket integration

Posted by Ophélie Salm <op...@zenika.com>.
@ Rodolfo : thanks for the tip, i'll try to check this out today.
actually the name of the project is databinder-valid-hib, and you can find it on the databinder maven repo. (that's a tip for anyone having a hard time finding this project ;)

@ Igor : that's exactly what i started with, a simple validator that can be added to any TextField, that's a starter but it's not enough.

Now IMHO it would be more convenient to have something like a global form validator, just like the HibernateFormValidator of the old hibernate-validator project. Or even better, an IComponentOnBeforeRenderListener.

The idea is to only specify validation in the model objects and you're done ! I'm tired of having to repeat myself to add the exact same validation both on the server side and the client side.

So, i'll try to have something up by the end of the week (hopefully) and share it with you. Basically, i'll focus on adapting the wicketstuff hibernate-validator.

Regards.

--
Ophélie Salm
Zenika
http://zenika.com
http://blog.zenika.com
http://yeswicket.com

Re: JSR 303 Wicket integration

Posted by James Carman <jc...@carmanconsulting.com>.
Perhaps a WIKI?

On Tue, Jan 12, 2010 at 4:28 PM, Rodolfo Hansen <kr...@gmail.com> wrote:
> Igor: which project would host this?
>
> On Tue, Jan 12, 2010 at 4:51 PM, Igor Vaynberg <ig...@gmail.com>wrote:
>
>> does it need a full blown project?
>>
>> BeanValidator<T> implements IValidator<T>
>> {
>>    @Dependency
>>    private transient Validator validator;
>>
>>    private final Class< ? > beanClass;
>>    private final String beanProperty;
>>
>>    public BeanValidator(Class< ? > beanClass, String beanProperty)
>>    {
>>        this.beanClass = beanClass;
>>        this.beanProperty = beanProperty;
>>    }
>>
>>    public void validate(IValidatable<T> validatable)
>>    {
>>        Object value = validatable.getValue();
>>        Set< ? > errors = validator.validateValue(beanClass,
>> beanProperty, value);
>>        for (Object error : errors)
>>        {
>>            ConstraintViolation< ? > violation = (ConstraintViolation<
>> ? >)error;
>>            ValidationError ve = new ValidationError();
>>            ve.setMessage(violation.getMessage());
>>            validatable.error(ve);
>>
>>        }
>>    }
>> }
>>
>> -igor
>>
>> On Tue, Jan 12, 2010 at 5:51 AM, Ophélie Salm <op...@zenika.com>
>> wrote:
>> > Hi all,
>> >
>> > I'm Ophélie @ Zenika !
>> >
>> > As the subject states, i've got a few questions regarding the JSR 303
>> (bean validation) integration with wicket. That's something a lot of people
>> at Zenika are eager to see evolving from the current "yes, it'd be great!"
>> project to a real concrete one. I know it's part of the wicket 1.5 wishlist
>> too, so i assume you might be interested as well ;)
>> >
>> > To be fair, this idea came up with this blog post :
>> http://magnus-k-karlsson.blogspot.com/2009/10/integrate-jsr-303-bean-validation-and.html
>> > but what we really want first, is to make bean validation available as a
>> form Behavior. Although it's still an open discussion.
>> >
>> > As i was searching the nabble archive, i noticed that the same subject
>> came up regularly, but i can't seem to find an ongoing project. However, i
>> stumbled upon the wicketstuff-hibernate-behavior made by Ryan Sonnek, which
>> is based on the Hibernate Validator framework. Unfortunately, this project
>> has moved to the attic due to lack of updates. So i was thinking about
>> starting over with this as a base project or inspiration, then to make it
>> fully compatible with wicket 1.4.x and of course the JSR 303.
>> >
>> > I know some people already did some blog posts, sharing their own code as
>> an answer to the JSR 303 integration, but what we want here, is to make it
>> available to a wider audience of wicket users, say, as a wicket stuff
>> component first and, why not, as part of wicket core later on.
>> >
>> > So, before starting anything, i need to know if someone is already taking
>> charge of a similar project ? If not, we're ready to dig into this matter
>> here at Zenika. So let me hear some feedback about this idea, what do you
>> think ?
>> >
>> > Regards.
>> > --
>> > Ophélie Salm
>> > Zenika
>> > http://www.zenika.com
>> > http://blog.zenika.com
>> > http://yeswicket.com
>> >
>>
>
>
>
> --
> Rodolfo Hansen
> CTO, KindleIT Software Development
> Email: rhansen@kindleit.net
> Mobile: +1 (809) 860-6669
>

Re: JSR 303 Wicket integration

Posted by Rodolfo Hansen <kr...@gmail.com>.
Igor: which project would host this?

On Tue, Jan 12, 2010 at 4:51 PM, Igor Vaynberg <ig...@gmail.com>wrote:

> does it need a full blown project?
>
> BeanValidator<T> implements IValidator<T>
> {
>    @Dependency
>    private transient Validator validator;
>
>    private final Class< ? > beanClass;
>    private final String beanProperty;
>
>    public BeanValidator(Class< ? > beanClass, String beanProperty)
>    {
>        this.beanClass = beanClass;
>        this.beanProperty = beanProperty;
>    }
>
>    public void validate(IValidatable<T> validatable)
>    {
>        Object value = validatable.getValue();
>        Set< ? > errors = validator.validateValue(beanClass,
> beanProperty, value);
>        for (Object error : errors)
>        {
>            ConstraintViolation< ? > violation = (ConstraintViolation<
> ? >)error;
>            ValidationError ve = new ValidationError();
>            ve.setMessage(violation.getMessage());
>            validatable.error(ve);
>
>        }
>    }
> }
>
> -igor
>
> On Tue, Jan 12, 2010 at 5:51 AM, Ophélie Salm <op...@zenika.com>
> wrote:
> > Hi all,
> >
> > I'm Ophélie @ Zenika !
> >
> > As the subject states, i've got a few questions regarding the JSR 303
> (bean validation) integration with wicket. That's something a lot of people
> at Zenika are eager to see evolving from the current "yes, it'd be great!"
> project to a real concrete one. I know it's part of the wicket 1.5 wishlist
> too, so i assume you might be interested as well ;)
> >
> > To be fair, this idea came up with this blog post :
> http://magnus-k-karlsson.blogspot.com/2009/10/integrate-jsr-303-bean-validation-and.html
> > but what we really want first, is to make bean validation available as a
> form Behavior. Although it's still an open discussion.
> >
> > As i was searching the nabble archive, i noticed that the same subject
> came up regularly, but i can't seem to find an ongoing project. However, i
> stumbled upon the wicketstuff-hibernate-behavior made by Ryan Sonnek, which
> is based on the Hibernate Validator framework. Unfortunately, this project
> has moved to the attic due to lack of updates. So i was thinking about
> starting over with this as a base project or inspiration, then to make it
> fully compatible with wicket 1.4.x and of course the JSR 303.
> >
> > I know some people already did some blog posts, sharing their own code as
> an answer to the JSR 303 integration, but what we want here, is to make it
> available to a wider audience of wicket users, say, as a wicket stuff
> component first and, why not, as part of wicket core later on.
> >
> > So, before starting anything, i need to know if someone is already taking
> charge of a similar project ? If not, we're ready to dig into this matter
> here at Zenika. So let me hear some feedback about this idea, what do you
> think ?
> >
> > Regards.
> > --
> > Ophélie Salm
> > Zenika
> > http://www.zenika.com
> > http://blog.zenika.com
> > http://yeswicket.com
> >
>



-- 
Rodolfo Hansen
CTO, KindleIT Software Development
Email: rhansen@kindleit.net
Mobile: +1 (809) 860-6669

Re: JSR 303 Wicket integration

Posted by Igor Vaynberg <ig...@gmail.com>.
does it need a full blown project?

BeanValidator<T> implements IValidator<T>
{
    @Dependency
    private transient Validator validator;

    private final Class< ? > beanClass;
    private final String beanProperty;

    public BeanValidator(Class< ? > beanClass, String beanProperty)
    {
        this.beanClass = beanClass;
        this.beanProperty = beanProperty;
    }

    public void validate(IValidatable<T> validatable)
    {
        Object value = validatable.getValue();
        Set< ? > errors = validator.validateValue(beanClass,
beanProperty, value);
        for (Object error : errors)
        {
            ConstraintViolation< ? > violation = (ConstraintViolation<
? >)error;
            ValidationError ve = new ValidationError();
            ve.setMessage(violation.getMessage());
            validatable.error(ve);

        }
    }
}

-igor

On Tue, Jan 12, 2010 at 5:51 AM, Ophélie Salm <op...@zenika.com> wrote:
> Hi all,
>
> I'm Ophélie @ Zenika !
>
> As the subject states, i've got a few questions regarding the JSR 303 (bean validation) integration with wicket. That's something a lot of people at Zenika are eager to see evolving from the current "yes, it'd be great!" project to a real concrete one. I know it's part of the wicket 1.5 wishlist too, so i assume you might be interested as well ;)
>
> To be fair, this idea came up with this blog post : http://magnus-k-karlsson.blogspot.com/2009/10/integrate-jsr-303-bean-validation-and.html
> but what we really want first, is to make bean validation available as a form Behavior. Although it's still an open discussion.
>
> As i was searching the nabble archive, i noticed that the same subject came up regularly, but i can't seem to find an ongoing project. However, i stumbled upon the wicketstuff-hibernate-behavior made by Ryan Sonnek, which is based on the Hibernate Validator framework. Unfortunately, this project has moved to the attic due to lack of updates. So i was thinking about starting over with this as a base project or inspiration, then to make it fully compatible with wicket 1.4.x and of course the JSR 303.
>
> I know some people already did some blog posts, sharing their own code as an answer to the JSR 303 integration, but what we want here, is to make it available to a wider audience of wicket users, say, as a wicket stuff component first and, why not, as part of wicket core later on.
>
> So, before starting anything, i need to know if someone is already taking charge of a similar project ? If not, we're ready to dig into this matter here at Zenika. So let me hear some feedback about this idea, what do you think ?
>
> Regards.
> --
> Ophélie Salm
> Zenika
> http://www.zenika.com
> http://blog.zenika.com
> http://yeswicket.com
>

Re: JSR 303 Wicket integration

Posted by Rodolfo Hansen <kr...@gmail.com>.
Have you checked out databinder-validator ?

It uses Hibernate Validator, but is a great place to start

I would be interested in throwing ideas arround.

On Tue, Jan 12, 2010 at 9:51 AM, Ophélie Salm <op...@zenika.com>wrote:

> Hi all,
>
> I'm Ophélie @ Zenika !
>
> As the subject states, i've got a few questions regarding the JSR 303 (bean
> validation) integration with wicket. That's something a lot of people at
> Zenika are eager to see evolving from the current "yes, it'd be great!"
> project to a real concrete one. I know it's part of the wicket 1.5 wishlist
> too, so i assume you might be interested as well ;)
>
> To be fair, this idea came up with this blog post :
> http://magnus-k-karlsson.blogspot.com/2009/10/integrate-jsr-303-bean-validation-and.html
> but what we really want first, is to make bean validation available as a
> form Behavior. Although it's still an open discussion.
>
> As i was searching the nabble archive, i noticed that the same subject came
> up regularly, but i can't seem to find an ongoing project. However, i
> stumbled upon the wicketstuff-hibernate-behavior made by Ryan Sonnek, which
> is based on the Hibernate Validator framework. Unfortunately, this project
> has moved to the attic due to lack of updates. So i was thinking about
> starting over with this as a base project or inspiration, then to make it
> fully compatible with wicket 1.4.x and of course the JSR 303.
>
> I know some people already did some blog posts, sharing their own code as
> an answer to the JSR 303 integration, but what we want here, is to make it
> available to a wider audience of wicket users, say, as a wicket stuff
> component first and, why not, as part of wicket core later on.
>
> So, before starting anything, i need to know if someone is already taking
> charge of a similar project ? If not, we're ready to dig into this matter
> here at Zenika. So let me hear some feedback about this idea, what do you
> think ?
>
> Regards.
> --
> Ophélie Salm
> Zenika
> http://www.zenika.com
> http://blog.zenika.com
> http://yeswicket.com
>



-- 
Rodolfo Hansen
CTO, KindleIT Software Development
Email: rhansen@kindleit.net
Mobile: +1 (809) 860-6669