String string = (String) object;
return string;
}
private static void validateEmptyString(FacesContext context, UIComponent component, String string) {
UIInput input = (UIInput) component;
if (input.isValid() && string != null && string.length() == 0) {
if (input.getValidators() != null) {
for (Validator validator : input.getValidators()) {
try {
validator.validate(context, input, string);
} catch (ValidatorException ve) {
// If the validator throws an exception, we're
// invalid, and we need to add a message
input.setValid(false);
FacesMessage message;
String validatorMessageString = input.getValidatorMessage();
if (null != validatorMessageString) {
message = new FacesMessage(FacesMessage.SEVERITY_ERROR, validatorMessageString,
validatorMessageString);
message.setSeverity(FacesMessage.SEVERITY_ERROR);
} else {
message = ve.getFacesMessage();
}
if (message != null) {
context.addMessage(input.getClientId(context), message);
}
}
}
}
}