// Get client id and init message + key
String clientId = component.getClientId();
- FacesMessage facesMessage = null;
+ String requiredMessage = null;
// So far all fine, no check if the field is fine
for (final String field : requiredFields) {
// Compare value's type
if ((!allowNull) && (!(value instanceof String))) {
// Value is empty
- facesMessage = new FacesMessage(MessageFormat.format("Field {0} is not String: {1}", field, value)); //NOI18N
+ requiredMessage = MessageFormat.format("Field {0} is not String: {1}", field, value); //NOI18N
}
// Cast to string
// Is it empty?
if (str.isEmpty()) {
- // Generate message
- facesMessage = new FacesMessage(MessageFormat.format("Field {0} is empty.", field)); //NOI18N
+ // Empty strings are currently not accepted, may indicate flaw in invoker
+ requiredMessage = MessageFormat.format("Field {0} is empty.", field); //NOI18N
}
}
}
// Debug message
- //this.getLogger().logDebug(MessageFormat.format("preValidate: facesMessage={0}", facesMessage)); //NOI18N
+ //this.getLogger().logDebug(MessageFormat.format("preValidate: requiredMessage={0}", requiredMessage)); //NOI18N
// Is it not null?
- if (null != facesMessage) {
- throw new ValidatorException(facesMessage);
+ if (null != requiredMessage) {
+ // Then there was something wrong with it
+ throw new ValidatorException(new FacesMessage(requiredMessage));
}
// Trace message