I used custom validators to get the error messages.
Code:
TextField field = new TextField();
field.addValidator(defaultValidators);
/*field.addValidator(new RegExValidator("^[a-zA-Z0-9]*", "Only alphanumericallowed"));*/
private Validator<String> defaultValidators = new AbstractValidator<String>() {
@Override
public List<EditorError> validate(Editor<String> editor, String value) {
List<EditorError> errors = null;
if(value==null)
return null;
if (!(value.matches("^[a-zA-Z0-9]*"))) {
errors= createError(editor, "Only alphanumeric allowed", value);
System.out.println(errors.get(0).getMessage());
}
return errors;
}
};
You can also try extending the inbuilt validators, and getting the messages by doing the similar changes in validate method.