private static ContactSessionBeanRemote CONTACT_BEAN;
/**
- * Pattern matcher
+ * Email pattern
*/
- private static final Pattern EMAIL_PATTERN = Pattern.compile(PizzaEmailAddressValidator.EMAIL_REGEX);
+ private static final String EMAIL_REGEX = "^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$"; //NOI18N
/**
- * Email pattern
+ * Pattern matcher
*/
- private static final String EMAIL_REGEX = "^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$"; //NOI18N
+ private static final Pattern PATTERN_MATCHER = Pattern.compile(PizzaEmailAddressValidator.EMAIL_REGEX);
/**
* Serial number
@Override
public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException {
- System.out.println("validate: value=" + value); //NOI18N
// The required field
String[] requiredFields = {"emailAddress", "emailAddressRepeat", "resendEmailAddress"}; //NOI18N
// Default is to reject empty email address fields
- Boolean allowEmptyEmail = Boolean.FALSE;
+ Boolean allowEmptyValue = Boolean.FALSE;
- // Is attribute "allowEmptyEmail" set?
- if (component.getAttributes().containsKey("allowEmptyEmail")) { //NOI18N
+ // Is attribute "allowEmptyValue" set?
+ if (component.getAttributes().containsKey("allowEmptyValue")) { //NOI18N
// Get attribute
- Object attribute = component.getAttributes().get("allowEmptyEmail"); //NOI18N
- System.out.println("attribute=" + attribute); //NOI18N
+ Object attribute = component.getAttributes().get("allowEmptyValue"); //NOI18N
// Make sure, it is Boolean as no String is accepted anymore
if (!(attribute instanceof String)) {
// Not valid attribute, please use "true" or "false" (default)
- throw new IllegalArgumentException("allowEmptyEmail must be of type String. Please use \"true\" or \"false\" for f:attribute value."); //NOI18N
+ throw new IllegalArgumentException("allowEmptyValue must be of type String. Please use \"true\" or \"false\" for f:attribute value."); //NOI18N
}
// Securely cast it
- allowEmptyEmail = Boolean.parseBoolean((String) attribute);
+ allowEmptyValue = Boolean.parseBoolean((String) attribute);
}
// Pre-validation (example: not null, not a string, empty string ...)
- super.preValidate(context, component, value, requiredFields, allowEmptyEmail);
+ super.preValidate(context, component, value, requiredFields, allowEmptyValue);
// Is the email address empty and allowed?
- if (null == value && allowEmptyEmail) {
+ if (null == value && allowEmptyValue) {
// Then accept this here
return;
} else if (null == value) {
// Checks if the email address matches a regex ("low-level" check)
// @TODO Should also be done by <f:validatorRegex />)
- boolean matches = EMAIL_PATTERN.matcher(emailAddress).matches(); //NOI18N
+ boolean matches = PATTERN_MATCHER.matcher(emailAddress).matches(); //NOI18N
// Is the email address valid?
if (!matches) {