You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Julien Martin <ba...@gmail.com> on 2011/10/20 21:30:36 UTC

Issue with Tapestry, JPA and JSR 303 annotations.

Hello,

I have the following property in one of my Tapestry classes:
*    @Property*
*    @Persist*
*    @Valid*
*    private ChildminderAccount childminderAccount;*


The ChildminderAccount entity extends an abstract Account entity class as
follows:
   *  public class ChildminderAccount extends Account*

And finally the Account entity class has several properties including this
one:
*    @NotNull*
*    private String accountFirstname;*

The problem I have is that Tapestry won't validate the annotated properties
even though I have added the tapestry-beanvalidator jar in the classpath.

Note that I don't use the beanform component for now.

I use T5.2.6.

Can anyone please help?

Regards,

Julien.

Re: Issue with Tapestry, JPA and JSR 303 annotations.

Posted by Julien Martin <ba...@gmail.com>.
Hello again,
I sorted the problem thanks to Igor's help as follows:
 <form t:type="form" t:id="childminderRegistrationForm" *
validate="childminderAccount"* clientValidation="none">
Thanks,
Julien.


2011/10/21 Julien Martin <ba...@gmail.com>

> Igor,
> Here is the page:
>
> *public class InscriptionProfessionnelGardeEnfant {*
> *
> *
> *    @Property*
> *    @Persist*
> *    @Valid*
> *    private ChildminderAccount childminderAccount;*
> *
> *
> *    @Property*
> *    private SelectModel childminderStatusSelectModel;*
> *
> *
> *    @Inject*
> *    private SelectModelFactory selectModelFactory;*
> *
> *
> *    @Property*
> *    @NotNull*
> *    private String accountPasswordConfirmation;*
> *
> *
> *    @Property*
> *    private List<ChildMinderStatus> childMinderStatusList;*
> *
> *
> *    @Inject*
> *    private BignibouService service;*
> *
> *
> *    @InjectComponent*
> *    private Form childminderRegistrationForm;*
> *
> *
> *    @OnEvent(EventConstants.PREPARE)*
> *    void prepare() {*
> *        childminderAccount = new ChildminderAccount();*
> *        childMinderStatusList = service.loadChildminderStatusList();*
> *        childminderStatusSelectModel =
> selectModelFactory.create(childMinderStatusList,"childMinderStatusDescription");
> *
> *    }*
> *
> *
> *    @OnEvent(value = EventConstants.VALIDATE, component =
> "childminderRegistrationForm")*
> *    void validateRegistrationForm() {*
> *        if (childminderRegistrationForm.isValid()) {*
> *            if
> (accountPasswordConfirmation.equals(childminderAccount.getAccountPassword()))
> {*
> *                service.persistChildminderAccount(childminderAccount);*
> *            }*
> *            else {*
> *             childminderRegistrationForm.recordError("passwords must
> match");//todo*
> *            }*
> *
> *
> *        } else {*
> *            System.out.println("something went wrong");*
> *            childminderRegistrationForm.recordError("something went
> wrong");//todo*
> *        }*
> *    }*
> *
> *
> *    @DiscardAfter*
> *    @OnEvent(EventConstants.SUCCESS)*
> *    void successfulRegistrationForm() {*
> *        System.out.println("success");*
> *
> *
> *    }*
> *
> *
> *}*
>
> ...and the template:
> *<t:sublayout xmlns:t="
> http://tapestry.apache.org/schema/tapestry_5_1_0.xsd">*
> *    <head>*
> *        <title>Hello World Page</title>*
> *    </head>*
> *    <body>*
> *    <form t:type="form" t:id="childminderRegistrationForm"
> validate="this" clientValidation="none">*
> *        <div>*
> *            <t:errors/>*
> *        </div>*
> *        <div>*
> *            <label t:type="label" for="accountEmailAddress"/>*
> *            <input t:type="textfield" t:id="accountEmailAddress"
> value="childminderAccount.accountEmailAddress"/>*
> *        </div>*
> *        <div>*
> *            <label t:type="label" for="accountFirstName"/>*
> *            <input t:type="textfield" t:id="accountFirstName"
> value="childminderAccount.accountFirstName"/>*
> *        </div>*
> *        <div>*
> *            <label t:type="label" for="accountLastName"/>*
> *            <input t:type="textfield" t:id="accountLastName"
> value="childminderAccount.accountLastName"/>*
> *        </div>*
> *        <div>*
> *            <label t:type="label" for="accountPassword"/>*
> *            <input t:type="textfield" t:id="accountPassword"
> value="childminderAccount.accountPassword"/>*
> *        </div>*
> *        <div>*
> *            <label t:type="label" for="accountPasswordConfirmation"/>*
> *            <input t:type="textfield" t:id="accountPasswordConfirmation"
> value="accountPasswordConfirmation"/>*
> *        </div>*
> *        <div>*
> *            <label t:type="label" for="postcode"/>*
> *            <input t:type="textfield" t:id="postcode" id="postcode"
> name="postcode" size="40"*
> *                   value="childminderAccount.postcodeByPostcodeId"
> translate="postcodeTranslator"/>*
> *        </div>*
> *        <div>*
> *            <input t:type="select" model="childminderStatusSelectModel"
> t:id="childminderStatus"*
> *
>  value="childminderAccount.childMinderStatusByChildMinderStatusId"
>  blankLabel="votre statut"/>*
> *        </div>*
> *        <div><input t:type="submit" type="submit" value="ok"/></div>*
> *    </form>*
> *    </body>*
> *</t:sublayout>*
>
> Can you please let me know how to pass the childminderAccount to the form's
> validate parameter? Do I do this in the template or the class?
> Regards,
>
> J.
>
> 2011/10/21 Igor Drobiazko <ig...@gmail.com>
>
>> Either the object graph is not traversed or your ChildminderAccount object
>> is null. The @Valid annotation is ignored for null objects. Please post
>> the
>> entire page class and template. You can also pass childminderAccount to
>> the
>> Form's validate parameter.
>>
>> On Thu, Oct 20, 2011 at 9:53 PM, Julien Martin <ba...@gmail.com> wrote:
>>
>> > Hi Igor,
>> >
>> > Yes I do use the form component as follows:
>> >
>> > From the class:
>> > *    @InjectComponent*
>> > *    private Form childminderRegistrationForm;*
>> > *
>> > *
>> > From template:
>> > *   <form t:type="form" t:id="childminderRegistrationForm"
>> validate="this"
>> > clientValidation="none">*
>> >
>> > Julien.
>> >
>> > 2011/10/20 Igor Drobiazko <ig...@gmail.com>
>> >
>> > > Please more details. "one of my Tapestry classes" is not precise
>> enough
>> > to
>> > > identify the problem. You are using the Form component, right? Did you
>> > use
>> > > the Form's validate parameter?
>> > >
>> > > On Thu, Oct 20, 2011 at 9:30 PM, Julien Martin <ba...@gmail.com>
>> wrote:
>> > >
>> > > > Hello,
>> > > >
>> > > > I have the following property in one of my Tapestry classes:
>> > > > *    @Property*
>> > > > *    @Persist*
>> > > > *    @Valid*
>> > > > *    private ChildminderAccount childminderAccount;*
>> > > >
>> > > >
>> > > > The ChildminderAccount entity extends an abstract Account entity
>> class
>> > as
>> > > > follows:
>> > > >   *  public class ChildminderAccount extends Account*
>> > > >
>> > > > And finally the Account entity class has several properties
>> including
>> > > this
>> > > > one:
>> > > > *    @NotNull*
>> > > > *    private String accountFirstname;*
>> > > >
>> > > > The problem I have is that Tapestry won't validate the annotated
>> > > properties
>> > > > even though I have added the tapestry-beanvalidator jar in the
>> > classpath.
>> > > >
>> > > > Note that I don't use the beanform component for now.
>> > > >
>> > > > I use T5.2.6.
>> > > >
>> > > > Can anyone please help?
>> > > >
>> > > > Regards,
>> > > >
>> > > > Julien.
>> > > >
>> > >
>> > >
>> > >
>> > > --
>> > > Best regards,
>> > >
>> > > Igor Drobiazko
>> > > http://tapestry5.de
>> > >
>> >
>>
>>
>>
>> --
>> Best regards,
>>
>> Igor Drobiazko
>> http://tapestry5.de
>>
>
>

Re: Issue with Tapestry, JPA and JSR 303 annotations.

Posted by Julien Martin <ba...@gmail.com>.
Igor,
Here is the page:

*public class InscriptionProfessionnelGardeEnfant {*
*
*
*    @Property*
*    @Persist*
*    @Valid*
*    private ChildminderAccount childminderAccount;*
*
*
*    @Property*
*    private SelectModel childminderStatusSelectModel;*
*
*
*    @Inject*
*    private SelectModelFactory selectModelFactory;*
*
*
*    @Property*
*    @NotNull*
*    private String accountPasswordConfirmation;*
*
*
*    @Property*
*    private List<ChildMinderStatus> childMinderStatusList;*
*
*
*    @Inject*
*    private BignibouService service;*
*
*
*    @InjectComponent*
*    private Form childminderRegistrationForm;*
*
*
*    @OnEvent(EventConstants.PREPARE)*
*    void prepare() {*
*        childminderAccount = new ChildminderAccount();*
*        childMinderStatusList = service.loadChildminderStatusList();*
*        childminderStatusSelectModel =
selectModelFactory.create(childMinderStatusList,"childMinderStatusDescription");
*
*    }*
*
*
*    @OnEvent(value = EventConstants.VALIDATE, component =
"childminderRegistrationForm")*
*    void validateRegistrationForm() {*
*        if (childminderRegistrationForm.isValid()) {*
*            if
(accountPasswordConfirmation.equals(childminderAccount.getAccountPassword()))
{*
*                service.persistChildminderAccount(childminderAccount);*
*            }*
*            else {*
*             childminderRegistrationForm.recordError("passwords must
match");//todo*
*            }*
*
*
*        } else {*
*            System.out.println("something went wrong");*
*            childminderRegistrationForm.recordError("something went
wrong");//todo*
*        }*
*    }*
*
*
*    @DiscardAfter*
*    @OnEvent(EventConstants.SUCCESS)*
*    void successfulRegistrationForm() {*
*        System.out.println("success");*
*
*
*    }*
*
*
*}*

...and the template:
*<t:sublayout xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd
">*
*    <head>*
*        <title>Hello World Page</title>*
*    </head>*
*    <body>*
*    <form t:type="form" t:id="childminderRegistrationForm" validate="this"
clientValidation="none">*
*        <div>*
*            <t:errors/>*
*        </div>*
*        <div>*
*            <label t:type="label" for="accountEmailAddress"/>*
*            <input t:type="textfield" t:id="accountEmailAddress"
value="childminderAccount.accountEmailAddress"/>*
*        </div>*
*        <div>*
*            <label t:type="label" for="accountFirstName"/>*
*            <input t:type="textfield" t:id="accountFirstName"
value="childminderAccount.accountFirstName"/>*
*        </div>*
*        <div>*
*            <label t:type="label" for="accountLastName"/>*
*            <input t:type="textfield" t:id="accountLastName"
value="childminderAccount.accountLastName"/>*
*        </div>*
*        <div>*
*            <label t:type="label" for="accountPassword"/>*
*            <input t:type="textfield" t:id="accountPassword"
value="childminderAccount.accountPassword"/>*
*        </div>*
*        <div>*
*            <label t:type="label" for="accountPasswordConfirmation"/>*
*            <input t:type="textfield" t:id="accountPasswordConfirmation"
value="accountPasswordConfirmation"/>*
*        </div>*
*        <div>*
*            <label t:type="label" for="postcode"/>*
*            <input t:type="textfield" t:id="postcode" id="postcode"
name="postcode" size="40"*
*                   value="childminderAccount.postcodeByPostcodeId"
translate="postcodeTranslator"/>*
*        </div>*
*        <div>*
*            <input t:type="select" model="childminderStatusSelectModel"
t:id="childminderStatus"*
*
 value="childminderAccount.childMinderStatusByChildMinderStatusId"
 blankLabel="votre statut"/>*
*        </div>*
*        <div><input t:type="submit" type="submit" value="ok"/></div>*
*    </form>*
*    </body>*
*</t:sublayout>*

Can you please let me know how to pass the childminderAccount to the form's
validate parameter? Do I do this in the template or the class?
Regards,

J.

2011/10/21 Igor Drobiazko <ig...@gmail.com>

> Either the object graph is not traversed or your ChildminderAccount object
> is null. The @Valid annotation is ignored for null objects. Please post the
> entire page class and template. You can also pass childminderAccount to the
> Form's validate parameter.
>
> On Thu, Oct 20, 2011 at 9:53 PM, Julien Martin <ba...@gmail.com> wrote:
>
> > Hi Igor,
> >
> > Yes I do use the form component as follows:
> >
> > From the class:
> > *    @InjectComponent*
> > *    private Form childminderRegistrationForm;*
> > *
> > *
> > From template:
> > *   <form t:type="form" t:id="childminderRegistrationForm"
> validate="this"
> > clientValidation="none">*
> >
> > Julien.
> >
> > 2011/10/20 Igor Drobiazko <ig...@gmail.com>
> >
> > > Please more details. "one of my Tapestry classes" is not precise enough
> > to
> > > identify the problem. You are using the Form component, right? Did you
> > use
> > > the Form's validate parameter?
> > >
> > > On Thu, Oct 20, 2011 at 9:30 PM, Julien Martin <ba...@gmail.com>
> wrote:
> > >
> > > > Hello,
> > > >
> > > > I have the following property in one of my Tapestry classes:
> > > > *    @Property*
> > > > *    @Persist*
> > > > *    @Valid*
> > > > *    private ChildminderAccount childminderAccount;*
> > > >
> > > >
> > > > The ChildminderAccount entity extends an abstract Account entity
> class
> > as
> > > > follows:
> > > >   *  public class ChildminderAccount extends Account*
> > > >
> > > > And finally the Account entity class has several properties including
> > > this
> > > > one:
> > > > *    @NotNull*
> > > > *    private String accountFirstname;*
> > > >
> > > > The problem I have is that Tapestry won't validate the annotated
> > > properties
> > > > even though I have added the tapestry-beanvalidator jar in the
> > classpath.
> > > >
> > > > Note that I don't use the beanform component for now.
> > > >
> > > > I use T5.2.6.
> > > >
> > > > Can anyone please help?
> > > >
> > > > Regards,
> > > >
> > > > Julien.
> > > >
> > >
> > >
> > >
> > > --
> > > Best regards,
> > >
> > > Igor Drobiazko
> > > http://tapestry5.de
> > >
> >
>
>
>
> --
> Best regards,
>
> Igor Drobiazko
> http://tapestry5.de
>

Re: Issue with Tapestry, JPA and JSR 303 annotations.

Posted by Igor Drobiazko <ig...@gmail.com>.
Either the object graph is not traversed or your ChildminderAccount object
is null. The @Valid annotation is ignored for null objects. Please post the
entire page class and template. You can also pass childminderAccount to the
Form's validate parameter.

On Thu, Oct 20, 2011 at 9:53 PM, Julien Martin <ba...@gmail.com> wrote:

> Hi Igor,
>
> Yes I do use the form component as follows:
>
> From the class:
> *    @InjectComponent*
> *    private Form childminderRegistrationForm;*
> *
> *
> From template:
> *   <form t:type="form" t:id="childminderRegistrationForm" validate="this"
> clientValidation="none">*
>
> Julien.
>
> 2011/10/20 Igor Drobiazko <ig...@gmail.com>
>
> > Please more details. "one of my Tapestry classes" is not precise enough
> to
> > identify the problem. You are using the Form component, right? Did you
> use
> > the Form's validate parameter?
> >
> > On Thu, Oct 20, 2011 at 9:30 PM, Julien Martin <ba...@gmail.com> wrote:
> >
> > > Hello,
> > >
> > > I have the following property in one of my Tapestry classes:
> > > *    @Property*
> > > *    @Persist*
> > > *    @Valid*
> > > *    private ChildminderAccount childminderAccount;*
> > >
> > >
> > > The ChildminderAccount entity extends an abstract Account entity class
> as
> > > follows:
> > >   *  public class ChildminderAccount extends Account*
> > >
> > > And finally the Account entity class has several properties including
> > this
> > > one:
> > > *    @NotNull*
> > > *    private String accountFirstname;*
> > >
> > > The problem I have is that Tapestry won't validate the annotated
> > properties
> > > even though I have added the tapestry-beanvalidator jar in the
> classpath.
> > >
> > > Note that I don't use the beanform component for now.
> > >
> > > I use T5.2.6.
> > >
> > > Can anyone please help?
> > >
> > > Regards,
> > >
> > > Julien.
> > >
> >
> >
> >
> > --
> > Best regards,
> >
> > Igor Drobiazko
> > http://tapestry5.de
> >
>



-- 
Best regards,

Igor Drobiazko
http://tapestry5.de

Re: Issue with Tapestry, JPA and JSR 303 annotations.

Posted by Julien Martin <ba...@gmail.com>.
up

2011/10/20 Julien Martin <ba...@gmail.com>

> Hi Igor,
>
> Yes I do use the form component as follows:
>
> From the class:
> *    @InjectComponent*
> *    private Form childminderRegistrationForm;*
> *
> *
> From template:
> *   <form t:type="form" t:id="childminderRegistrationForm" validate="this"
> clientValidation="none">*
>
> Julien.
>
> 2011/10/20 Igor Drobiazko <ig...@gmail.com>
>
>> Please more details. "one of my Tapestry classes" is not precise enough to
>> identify the problem. You are using the Form component, right? Did you use
>> the Form's validate parameter?
>>
>> On Thu, Oct 20, 2011 at 9:30 PM, Julien Martin <ba...@gmail.com> wrote:
>>
>> > Hello,
>> >
>> > I have the following property in one of my Tapestry classes:
>> > *    @Property*
>> > *    @Persist*
>> > *    @Valid*
>> > *    private ChildminderAccount childminderAccount;*
>> >
>> >
>> > The ChildminderAccount entity extends an abstract Account entity class
>> as
>> > follows:
>> >   *  public class ChildminderAccount extends Account*
>> >
>> > And finally the Account entity class has several properties including
>> this
>> > one:
>> > *    @NotNull*
>> > *    private String accountFirstname;*
>> >
>> > The problem I have is that Tapestry won't validate the annotated
>> properties
>> > even though I have added the tapestry-beanvalidator jar in the
>> classpath.
>> >
>> > Note that I don't use the beanform component for now.
>> >
>> > I use T5.2.6.
>> >
>> > Can anyone please help?
>> >
>> > Regards,
>> >
>> > Julien.
>> >
>>
>>
>>
>> --
>> Best regards,
>>
>> Igor Drobiazko
>> http://tapestry5.de
>>
>
>

Re: Issue with Tapestry, JPA and JSR 303 annotations.

Posted by Julien Martin <ba...@gmail.com>.
Hi Igor,

Yes I do use the form component as follows:

>From the class:
*    @InjectComponent*
*    private Form childminderRegistrationForm;*
*
*
>From template:
*   <form t:type="form" t:id="childminderRegistrationForm" validate="this"
clientValidation="none">*

Julien.

2011/10/20 Igor Drobiazko <ig...@gmail.com>

> Please more details. "one of my Tapestry classes" is not precise enough to
> identify the problem. You are using the Form component, right? Did you use
> the Form's validate parameter?
>
> On Thu, Oct 20, 2011 at 9:30 PM, Julien Martin <ba...@gmail.com> wrote:
>
> > Hello,
> >
> > I have the following property in one of my Tapestry classes:
> > *    @Property*
> > *    @Persist*
> > *    @Valid*
> > *    private ChildminderAccount childminderAccount;*
> >
> >
> > The ChildminderAccount entity extends an abstract Account entity class as
> > follows:
> >   *  public class ChildminderAccount extends Account*
> >
> > And finally the Account entity class has several properties including
> this
> > one:
> > *    @NotNull*
> > *    private String accountFirstname;*
> >
> > The problem I have is that Tapestry won't validate the annotated
> properties
> > even though I have added the tapestry-beanvalidator jar in the classpath.
> >
> > Note that I don't use the beanform component for now.
> >
> > I use T5.2.6.
> >
> > Can anyone please help?
> >
> > Regards,
> >
> > Julien.
> >
>
>
>
> --
> Best regards,
>
> Igor Drobiazko
> http://tapestry5.de
>

Re: Issue with Tapestry, JPA and JSR 303 annotations.

Posted by Igor Drobiazko <ig...@gmail.com>.
Please more details. "one of my Tapestry classes" is not precise enough to
identify the problem. You are using the Form component, right? Did you use
the Form's validate parameter?

On Thu, Oct 20, 2011 at 9:30 PM, Julien Martin <ba...@gmail.com> wrote:

> Hello,
>
> I have the following property in one of my Tapestry classes:
> *    @Property*
> *    @Persist*
> *    @Valid*
> *    private ChildminderAccount childminderAccount;*
>
>
> The ChildminderAccount entity extends an abstract Account entity class as
> follows:
>   *  public class ChildminderAccount extends Account*
>
> And finally the Account entity class has several properties including this
> one:
> *    @NotNull*
> *    private String accountFirstname;*
>
> The problem I have is that Tapestry won't validate the annotated properties
> even though I have added the tapestry-beanvalidator jar in the classpath.
>
> Note that I don't use the beanform component for now.
>
> I use T5.2.6.
>
> Can anyone please help?
>
> Regards,
>
> Julien.
>



-- 
Best regards,

Igor Drobiazko
http://tapestry5.de