I've been given a page design that has 4 text boxes and 4 submit buttons. I only need 
to validate the text box associated with the submit button that was clicked. required 
and requiredIf don't seem to be what I'm looking for.  Right now, my action form's 
validate looks like this:
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    ActionErrors errors = new ActionErrors();
    String action = request.getParameter("method");
    if (action.equals("queryByDate")) {
        validateDate(errors);
    } else if (action.equals("queryByPro")) {
        validatePro(errors);
    } else if (action.equals("queryByBol")) {
        validateBol(errors);
    } else if (action.equals("queryByAuth")) {
        validateAuth(errors);
    } else if (action.equals("queryByPart")) {
        validatePart(errors);
    } else {
        errors.add("unknown query method", new ActionError("query_method.unknown"));
    }
    return errors;
}

And each of the private validate* methods are similar to this:

private void validatePro(ActionErrors errors) {
    if (!validator.match(PRO_VAL_REG_EXP, proNumber)) {
        errors.add("proNumber", new ActionError("proNumber.format"));
    }
}

But I'd like a more elegant solution. Especially, I'd like to be able to specify the 
regular expression used to validate each field outside of the class. In order to do 
that, I think I need to use DynaValidatorActionForm, but I'm not sure how to setup the 
"only-validate-if-this-submit-clicked" logic.

Any suggestions would be appreciated.

Thanks.

Eric

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

Reply via email to