You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by ayman elwany <ay...@gmail.com> on 2010/01/04 07:33:45 UTC
Integrating Hibernate Validator with Wicket
Hi,
Is there any common practice to integrate wicket with hibernate validator ?
Re: Integrating Hibernate Validator with Wicket
Posted by prati <pr...@gmail.com>.
Hi
I integrated Hibernate Validator given in Wicket stuff with my application
I am getting this error
org.hibernate.PropertyValueException: not-null property references a null or
transient value:
Any ideas?
Thanks
P
Carlos Vara wrote:
>
> Hi,
>
> if you prefer to use JSR 303 Bean Validation (it's very similar to
> Hibernate
> Validator, in fact, it is the reference implementation), I made a blog
> post
> about how to integrate it with Wicket:
>
> http://carinae.net/2009/12/integration-of-jsr-303-bean-validation-standard-and-wicket-1-4/
>
>
> On Mon, Jan 4, 2010 at 11:28 AM, ayman elwany <ay...@gmail.com>
> wrote:
>
>> thanks Martin for the link , I used it but I had a problem;
>>
>>
>> public class CarPage extends WebPage {
>>
>> * ......*
>> * ......*
>> UserModel user=
>> ((LoginSession)getSession()).getUserBean();
>> * ......*
>> * ......*
>> * ......*
>> private void fillPersonalInfoComponents(Form personalForm) {
>> * ......*
>> * ...... *
>> PropertyModel fullnamepropertyModel =new
>> PropertyModel<String>(user, "fullNameValue");
>> fullName = new TextField("fullName", fullnamepropertyModel);
>> personalForm.add(fullName);
>> //System.out.println("Model =
>> "+fullnamepropertyModel.getChainedModel().getClass().getName());
>> fullName.add(new HibernateValidator<String>(fullnamepropertyModel,
>> "fullNameValue"));
>>
>> }
>> }
>>
>>
>>
>> And the user model is
>>
>> public class UserModel implements Serializable {
>>
>> /**
>> *
>> */
>> private static final long serialVersionUID = 1011452297289823651L;
>> * ......*
>> * ......*
>> * ......*
>>
>> @NotNull
>> @NotEmpty
>> private String fullNameValue;
>> * ......*
>> * ......*
>> * ......*
>> }
>>
>>
>> but it always fails and gives me that my model is null . but the strange
>> behaviour that when I changed HibernateValidator constructor
>>
>> *from*
>>
>> public HibernateValidator(I*Model entityModel*, String property) {
>> this.property = property;
>> if (entityModel != null)
>> hibernateValidator = new
>> ClassValidator(*entityModel.getObject().getClass()*
>> );
>> }
>>
>>
>> *TO*
>> public HibernateValidator(*Object bean, *String property) {
>> this.property = property;
>> //if (entityModel != null)
>> hibernateValidator = new ClassValidator(*bean.getClass()*);
>> }
>>
>> and did this
>>
>> fullName.add(new HibernateValidator<String>(user, "fullNameValue"));
>>
>> the validation worked *fine *!!!
>>
>> so is there is any problem in the propertymodel with hibernate
>> validator???
>>
>> On Mon, Jan 4, 2010 at 8:37 AM, Martin Makundi <
>> martin.makundi@koodaripalvelut.com> wrote:
>>
>> > http://42lines.net/content/integrating-hibernate-validator-and-wicket
>> >
>> > 2010/1/4 ayman elwany <ay...@gmail.com>:
>> > > Hi,
>> > >
>> > > Is there any common practice to integrate wicket with hibernate
>> validator
>> > ?
>> > >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> > For additional commands, e-mail: users-help@wicket.apache.org
>> >
>> >
>>
>
>
--
View this message in context: http://old.nabble.com/Integrating-Hibernate-Validator-with-Wicket-tp27009326p27607538.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Integrating Hibernate Validator with Wicket
Posted by Carlos Vara <ba...@gmail.com>.
Hi,
if you prefer to use JSR 303 Bean Validation (it's very similar to Hibernate
Validator, in fact, it is the reference implementation), I made a blog post
about how to integrate it with Wicket:
http://carinae.net/2009/12/integration-of-jsr-303-bean-validation-standard-and-wicket-1-4/
On Mon, Jan 4, 2010 at 11:28 AM, ayman elwany <ay...@gmail.com> wrote:
> thanks Martin for the link , I used it but I had a problem;
>
>
> public class CarPage extends WebPage {
>
> * ......*
> * ......*
> UserModel user= ((LoginSession)getSession()).getUserBean();
> * ......*
> * ......*
> * ......*
> private void fillPersonalInfoComponents(Form personalForm) {
> * ......*
> * ...... *
> PropertyModel fullnamepropertyModel =new
> PropertyModel<String>(user, "fullNameValue");
> fullName = new TextField("fullName", fullnamepropertyModel);
> personalForm.add(fullName);
> //System.out.println("Model =
> "+fullnamepropertyModel.getChainedModel().getClass().getName());
> fullName.add(new HibernateValidator<String>(fullnamepropertyModel,
> "fullNameValue"));
>
> }
> }
>
>
>
> And the user model is
>
> public class UserModel implements Serializable {
>
> /**
> *
> */
> private static final long serialVersionUID = 1011452297289823651L;
> * ......*
> * ......*
> * ......*
>
> @NotNull
> @NotEmpty
> private String fullNameValue;
> * ......*
> * ......*
> * ......*
> }
>
>
> but it always fails and gives me that my model is null . but the strange
> behaviour that when I changed HibernateValidator constructor
>
> *from*
>
> public HibernateValidator(I*Model entityModel*, String property) {
> this.property = property;
> if (entityModel != null)
> hibernateValidator = new
> ClassValidator(*entityModel.getObject().getClass()*
> );
> }
>
>
> *TO*
> public HibernateValidator(*Object bean, *String property) {
> this.property = property;
> //if (entityModel != null)
> hibernateValidator = new ClassValidator(*bean.getClass()*);
> }
>
> and did this
>
> fullName.add(new HibernateValidator<String>(user, "fullNameValue"));
>
> the validation worked *fine *!!!
>
> so is there is any problem in the propertymodel with hibernate validator???
>
> On Mon, Jan 4, 2010 at 8:37 AM, Martin Makundi <
> martin.makundi@koodaripalvelut.com> wrote:
>
> > http://42lines.net/content/integrating-hibernate-validator-and-wicket
> >
> > 2010/1/4 ayman elwany <ay...@gmail.com>:
> > > Hi,
> > >
> > > Is there any common practice to integrate wicket with hibernate
> validator
> > ?
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
Re: Integrating Hibernate Validator with Wicket
Posted by ayman elwany <ay...@gmail.com>.
thanks Martin for the link , I used it but I had a problem;
public class CarPage extends WebPage {
* ......*
* ......*
UserModel user= ((LoginSession)getSession()).getUserBean();
* ......*
* ......*
* ......*
private void fillPersonalInfoComponents(Form personalForm) {
* ......*
* ...... *
PropertyModel fullnamepropertyModel =new
PropertyModel<String>(user, "fullNameValue");
fullName = new TextField("fullName", fullnamepropertyModel);
personalForm.add(fullName);
//System.out.println("Model =
"+fullnamepropertyModel.getChainedModel().getClass().getName());
fullName.add(new HibernateValidator<String>(fullnamepropertyModel,
"fullNameValue"));
}
}
And the user model is
public class UserModel implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1011452297289823651L;
* ......*
* ......*
* ......*
@NotNull
@NotEmpty
private String fullNameValue;
* ......*
* ......*
* ......*
}
but it always fails and gives me that my model is null . but the strange
behaviour that when I changed HibernateValidator constructor
*from*
public HibernateValidator(I*Model entityModel*, String property) {
this.property = property;
if (entityModel != null)
hibernateValidator = new ClassValidator(*entityModel.getObject().getClass()*
);
}
*TO*
public HibernateValidator(*Object bean, *String property) {
this.property = property;
//if (entityModel != null)
hibernateValidator = new ClassValidator(*bean.getClass()*);
}
and did this
fullName.add(new HibernateValidator<String>(user, "fullNameValue"));
the validation worked *fine *!!!
so is there is any problem in the propertymodel with hibernate validator???
On Mon, Jan 4, 2010 at 8:37 AM, Martin Makundi <
martin.makundi@koodaripalvelut.com> wrote:
> http://42lines.net/content/integrating-hibernate-validator-and-wicket
>
> 2010/1/4 ayman elwany <ay...@gmail.com>:
> > Hi,
> >
> > Is there any common practice to integrate wicket with hibernate validator
> ?
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: Integrating Hibernate Validator with Wicket
Posted by Martin Makundi <ma...@koodaripalvelut.com>.
http://42lines.net/content/integrating-hibernate-validator-and-wicket
2010/1/4 ayman elwany <ay...@gmail.com>:
> Hi,
>
> Is there any common practice to integrate wicket with hibernate validator ?
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org