GeeCON Prague 2014*
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


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "plugin validator messages not printing" Watch "plugin validator messages not printing" New topic
Author

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.

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 ]

SCBCD (Preparing) <br />SCWCD, 82%<br />SCJP, 90%
 
GeeCON Prague 2014
 
subject: plugin validator messages not printing