开发者

Class Level Validation in Seam/Hibernate

开发者 https://www.devze.com 2023-01-28 09:20 出处:网络
I implemented a custom c开发者_开发百科lass level validator in my seam/hibernate application.On my form I have <s:validateAll>.This tag does not call the class level validation.

I implemented a custom c开发者_开发百科lass level validator in my seam/hibernate application. On my form I have <s:validateAll>. This tag does not call the class level validation.

Related issue: https://jira.jboss.org/browse/JBSEAM-1878

What is the best way for me to call this validation using Seam/JSF/RichFaces?


Have you used the validator attribute? You have to use that together with either s:validateAll or s:validate

This is maybe not what you mean by hibernate class level validation, but at least it will work

For instance:

<h:inputText value="#{foo.bar}" validator="#{validator.checkFoo}" required="true">
  <s:validate/>
</h:inputText>

And validator

@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);
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消