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/15 18:21:04 UTC

Complex use case about JSR-303, Tapestry, and JPA entity inheritance

Hello,

I have a JPA entity called ParentAccount that extends an abstract Account
entity (see JPA inheritance). I have place the JSR-303 validation
constraints in the Account entity.
Now I have the following Tapestry class and templates and jsr-303 validation
does not seem to work:

*public class Inscription {*
*
*
*    @Property*
*    //this is not validated...*
*    private ParentAccount parentAccount;*
*
*
*    @Property*
*    @Validate("required")*
*    private String accountPasswordConfirmation;*
*
*
*
*
*    @InjectComponent*
*    private Form registrationForm;*
*
*
*    @OnEvent(EventConstants.PREPARE)*
*    void prepareAccount(){*
*        parentAccount = new ParentAccount() ;*
*    }*
*
*
*    @OnEvent(value= EventConstants.VALIDATE)*
*    void validateRegistrationForm(){*
*        if(registrationForm.isValid()){*
*         if(accountPasswordConfirmation.equals(
parentAccount.getAccountPassword()))  {*
*            System.out.println("ok for insert");*
*         }*
*        }*
*    }*
*
*
*
*
*}*
*
*
<html 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="registrationForm" validate="this">
    <t:errors/>
    <div>
        <label t:type="label" for="accountEmailAddress"/>
        <input t:type="textfield" t:id="accountEmailAddress"
value="parentAccount.accountEmailAddress"/>
    </div>
    <div>
        <label t:type="label" for="accountFirstName"/>
        <input t:type="textfield" t:id="accountFirstName"
value="parentAccount.accountFirstName"/>
    </div>
    <div>
        <label t:type="label" for="accountLastName"/>
        <input t:type="textfield" t:id="accountLastName"
value="parentAccount.accountLastName"/>
    </div>
    <div>
        <label t:type="label" for="accountPassword"/>
        <input t:type="textfield" t:id="accountPassword"
value="parentAccount.accountPassword"/>
    </div>
    <div>
        <label t:type="label" for="accountPasswordConfirmation"/>
        <input t:type="textfield" t:id="accountPasswordConfirmation"
value="accountPasswordConfirmation"/>
    </div>
    <div><input type="submit" value="ok"/></div>
</form>
</body>
</html>

I get a NPE here (*parentAccount.getAccountPassword*) indicating that the
NotNull annotation that I have placed in the Account entity is ignored...

Note that I deliberately don't use a beanform for now.

Can anyone please help?

Regards,

Julien.