I am developing an application using Tomcat 7, JSF 2.2.6 (Mojarra), Hibernate Validator 4.3.1 and have come across the well documented bug shown here: https://java.net/jira/browse/JAVASERVERFACES-3183.
I have patched this temporarily using the fix given in this answer on another question: https://stackoverflow.com/a/21700488/1089995, until such a time as 2.2.7 is released publicly.
However when I attempt to use Annotations on fields, such as @NotNull, @Size, etc, these are simply ignored - there is no relevant stack trace for this, no error occurs, the annotations are simply ignored during the Validation phase.
page.xhtml
<input type="text" placeholder="e.g. Joe Bloggs" jsf:id="txtAdminName" jsf:validator="#{bean.validateAdminName}" jsf:value="#{bean.model.adminName}"/>
Model.java
//model bean with bean validation, which is not applied to the field.
@Size(min = 3, max = 50, message = "Please enter between 3 and 50 characters.")
private String adminName;
Bean.java
//the model bean with Bean Validation, as shown below.
private Model model;
//JSF Validator method, works fine
public void validateAdminName(FacesContext context, UIComponent component, Object convertedValue) {
String adminName = convertedValue.toString();
if(adminName.matches(".*[0-9].*")) {
//not valid
throw new ValidatorException(new FacesMessage("Please enter a valid name."));
}
}
Is this an isolated problem, or does the temporary fix simply not allow the use of @Annotations? Any ideas would be much appreciated.
Thanks.
Edit: added sample working validator method source code, added info regarding lack of relevant stack trace.