Hello Everyone,
i have a validation to check if zip belongs to a state.
in FieldsCheck.java
-------------------
public static boolean validateZipCodeInState(Object bean,
ValidatorAction va,
Field field,
ActionErrors errors,
HttpServletRequest request) {
String zip = ValidatorUtils.getValueAsString(bean, field.getProperty());
String sProperty2 = field.getVarValue("secondProperty");
String state = ValidatorUtils.getValueAsString(bean, sProperty2);
if (!GenericValidator.isBlankOrNull(zip) && !VALIDATOR.checkZipCodeValidInState(zip, state)) {
// option 1 tried
addError(errors, request, "ActionErrors.GLOBAL_ERROR", Resources.getActionMessage(request, va, field));
//option 2 tried
addError(errors, request, "ActionErrors.GLOBAL_ERROR", new ActionMessage("Error in zip state"));
// option 3 tried
addError(errors, request, field.getKey(),Resources.getActionMessage(request, va, field));
return false;
}
return true;
}
protected static final ActionErrors addError(ActionErrors errors, HttpServletRequest request, String key, ActionMessage actionMessage) {
if (errors == null) {
errors = new ActionErrors();
//option 1 tried
request.setAttribute(ActionErrors.GLOBAL_ERROR, errors);
// option 2 tried
request.setAttribute(Globals.ERROR_KEY, errors);
}
errors.add(key, actionMessage);
request.setAttribute(ActionErrors.GLOBAL_ERROR, errors);
return errors;
}
in the log messages, it returns false for incorrent zip but still not printing my message on the html form... i've tried a couple of things but
in vain.
Please help.
Thanks!
[ November 16, 2005: Message edited by: Bhumika Thakkar ]