Hi all,
I'm trying to use this custom validate method.  I got the instructions from Matt
Raible's site (thanks Matt ;-)):
http://www.raibledesigns.com/page/rd/20030226

I remember this used to work, but now it's not.  I'm using Struts 1.2.4 and
commons-validator 1.1.3.  I've been playing with it a little and found that the
problem is that the incoming errors parameter is null.  I know something
concerning ActionErrors has gone into place with the recent struts releases
(i.e. "don't use ActionErrors", I think?)  Anyways, I'd like to write a few
other custom validation methods, which is really why I'm planning on using
Struts for my current project.  Has anyone figured out this problem or know of
any other documentation.

  public static boolean validateTwoFields(Object bean, ValidatorAction va,
                                        Field field, ActionErrors errors,
                                        HttpServletRequest request) {
    String value =
        ValidatorUtils.getValueAsString(bean, field.getProperty());
    String sProperty2 = field.getVarValue("secondProperty");
    String value2 = ValidatorUtils.getValueAsString(bean, sProperty2);

    LOG.debug("errors: "+errors);  // this is null

    if (!GenericValidator.isBlankOrNull(value)) {
        try {
            if (!value.equals(value2)) {
                errors.add(field.getKey(),
                           Resources.getActionError(request, va, field));

                return false;
            }
        } catch (Exception e) {
            errors.add(field.getKey(),
                       Resources.getActionError(request, va, field));

            return false;
        }
    }

Thanks,
Ben

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to