How to enable JSR-303 bean validation in Facelets?
I'm using spring CDI and a customized "View" scope. (See this about how it works.)
The view bean is annotated with JSR-303 validation rules as following:
@Scope("view")
public class MyBean implements Serializable {
String message;
@NotNull
@Size(min = 10)
public String getMessage() {
return message;
}
public void setMessage(String message) 开发者_开发技巧{
this.message = message;
}
public void action1() {
...
}
}
And the user form:
...
<h:form id="form1">
<h:inputText name="message" value="${myBean.message}" />
<p:commandButton value="Update" actionListener="${myBean.action1}" />
</h:form>
However, the validation doesn't work. Am I missing something in faces-config.xml
? I guess there should be some proxy classes involved in, which maybe generated by AspectJ weaver or so. Right?
JSR 303 validation for JSF is auto enabled if you add implementation jar to classpath.
精彩评论