The moose likes Struts and the fly likes plugin validator messages not printing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "plugin validator messages not printing" Watch "plugin validator messages not printing" New topic

plugin validator messages not printing

Bhumika Thakkar
Ranch Hand

Joined: Apr 18, 2005
Posts: 79
Hello Everyone,

i have a validation to check if zip belongs to a state.


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.

[ November 16, 2005: Message edited by: Bhumika Thakkar ]

SCBCD (Preparing) <br />SCWCD, 82%<br />SCJP, 90%
It is sorta covered in the JavaRanch Style Guide.
subject: plugin validator messages not printing
It's not a secret anymore!