【问题标题】:Class Level Validation in Seam/HibernateSeam/Hibernate 中的类级别验证
【发布时间】:2010-12-02 17:28:48
【问题描述】:
【问题讨论】:
标签:
hibernate
jsf
richfaces
seam
【解决方案1】:
您是否使用过validator 属性?您必须将其与 s:validateAll 或 s:validate 一起使用
这可能不是你所说的休眠类级别验证,但至少它会起作用
例如:
<h:inputText value="#{foo.bar}" validator="#{validator.checkFoo}" required="true">
<s:validate/>
</h:inputText>
和验证器
@Name("validator")
@Scope(ScopeType.EVENT)
@BypassInterceptors
public class Validator {
public void checkFoo(FacesContext context, UIComponent toValidate, Object value) {
//Do some check and if incorrect set this value
((UIInput) toValidate).setValid(false);
}
}