Example usage for org.apache.commons.validator ValidatorAction getMsg

List of usage examples for org.apache.commons.validator ValidatorAction getMsg

Introduction

In this page you can find the example usage for org.apache.commons.validator ValidatorAction getMsg.

Prototype

public String getMsg() 

Source Link

Document

Gets the message associated with the validator action.

Usage

From source file:org.megatome.frame2.validator.CommonsFieldValidator.java

/**
 * Add an error to the Errors object/*from ww  w  .j  av  a 2  s  .  c  o m*/
 * 
 * @param va
 *            Validator action
 * @param errors
 *            Errors object to populate
 * @param field
 *            The field to use when creating the Error
 * @param validatorErrorValue1
 *            First error value to use
 * @param validatorErrorValue2
 *            Second error value to use
 */
protected static void addError(ValidatorAction va, Errors errors, Field field, Object validatorErrorValue1,
        Object validatorErrorValue2) {
    Arg arg = field.getArg(0);
    String validatorKey = va.getMsg();
    if (arg != null) {
        String fieldMsgKey = arg.getKey();
        if (fieldMsgKey != null) {
            Error fieldMsg = ErrorFactory.createError(fieldMsgKey);
            Error validateError = ErrorFactory.createError(validatorKey, fieldMsg, validatorErrorValue1,
                    validatorErrorValue2);
            errors.add(validateError);
        }
    }
}

From source file:org.springmodules.commons.validator.MessageUtils.java

/**
 * Gets the <code>ActionError</code> based on the <code>ValidatorAction</code> message and the <code>Field</code>'s
 * arg objects.//from   w ww  . j a  v  a 2 s .  c  o  m
 * <p/>
 */
public static String getMessageKey(ValidatorAction va, Field field) {
    return (field.getMsg(va.getName()) != null ? field.getMsg(va.getName()) : va.getMsg());
}