Account
엔티티 (JPA 상속 참조)를 확장하는 ParentAccount
이라는 JPA 엔티티가 있습니다. Account 개체에 JSR-303 유효성 검사 제약 조건을 배치했습니다.JSR-303, Tapestry 및 JPA 엔티티 상속에 대한 복잡한 사용 사례
태피스트리 클래스 :
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");
}
}
}
}
태피스트리 페이지 : 은 지금은하지 않는 것 태피스트리 클래스와 템플릿과 JSR-303 검증 다음은 일을해야 불행하게도
<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 @NotNull
주석이있는 항목에 주석을 추가 한 경우 해당 JSR-303 제약 조건은 무시됩니다.
아무도 도와 줄 수 있습니까?
감사합니다,
Tapestry 클래스의 속성에 JSR-303 주석을 추가하면 고려해야한다는 것을 알게되었습니다. 왜 Tapestry는 JPA 엔티티의 속성에 배치 될 때 주석을 고려하지 않을까요 ?? – balteo