• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

plugin validator messages not printing

 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Attractive, successful people love this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic