Hi;

I am using a really simple property file, to display some validation errors,
it used to work fine, but it stopped working, now I can't even get the
simplest example to work. and I am receiving an Could not locate error
message for component:


Here's the code that I am using(directly from cookbook), and I have
PasswordPolicyValidator.properties file in the same folder
package cookbook;

import java.util.regex.Pattern;

import org.apache.wicket.validation.IValidatable;
import org.apache.wicket.validation.IValidator;
import org.apache.wicket.validation.ValidationError;

public class PasswordPolicyValidator implements IValidator<String> {

private static final Pattern UPPER = Pattern.compile("[A-Z]");
private static final Pattern LOWER = Pattern.compile("[a-z]");
private static final Pattern NUMBER = Pattern.compile("[0-9]");

public void validate(IValidatable<String> validatable) {
final String password = validatable.getValue();

if (!NUMBER.matcher(password).find()) {
error(validatable, "no-digit");
}

if (!LOWER.matcher(password).find()) {
error(validatable, "no-lower");
}

if (!UPPER.matcher(password).find()) {
error(validatable, "no-upper");
}
}

private void error(IValidatable<String> validatable, String errorKey) {
ValidationError error = new ValidationError();
error.addMessageKey(getClass().getSimpleName() + "." + errorKey);
validatable.error(error);
}

}

PasswordPolicyValidator.no-digit=${label} must contain at least one digit
PasswordPolicyValidator.no-lower=${label} must contain at least one lower
case letter
PasswordPolicyValidator.no-upper=${label} must contain at least one upper
case letter

Erinc

Reply via email to