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

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

Introduction

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

Prototype

public String getMsg(String key) 

Source Link

Document

Retrieve a message value.

Usage

From source file:org.apache.struts.validator.Resources.java

/**
 * Gets the locale sensitive message based on the <code>ValidatorAction</code>
 * message and the <code>Field</code>'s arg objects.
 *
 * @param messages The Message resources
 * @param locale   The locale/*  w  ww .  j  a  v a2 s . c  om*/
 * @param va       The Validator Action
 * @param field    The Validator Field
 */
public static String getMessage(MessageResources messages, Locale locale, ValidatorAction va, Field field) {
    String[] args = getArgs(va.getName(), messages, locale, field);
    String msg = (field.getMsg(va.getName()) != null) ? field.getMsg(va.getName()) : va.getMsg();

    return messages.getMessage(locale, msg, args);
}

From source file:org.apache.struts.validator.Resources.java

/**
 * Gets the <code>ActionMessage</code> based on the
 * <code>ValidatorAction</code> message and the <code>Field</code>'s arg
 * objects.//  w  w w  .  jav a 2  s.c  o  m
 * <p>
 * <strong>Note:</strong> this method does not respect bundle information
 * stored with the field's &lt;msg&gt; or &lt;arg&gt; elements, and localization
 * will not work for alternative resource bundles. This method is
 * deprecated for this reason, and you should use
 * {@link #getActionMessage(Validator,HttpServletRequest,ValidatorAction,Field)}
 * instead. 
 *
 * @param request the servlet request
 * @param va      Validator action
 * @param field   the validator Field
 * @deprecated Use getActionMessage(Validator, HttpServletRequest,
 *    ValidatorAction, Field) method instead
 */
public static ActionMessage getActionMessage(HttpServletRequest request, ValidatorAction va, Field field) {
    String[] args = getArgs(va.getName(), getMessageResources(request),
            RequestUtils.getUserLocale(request, null), field);

    String msg = (field.getMsg(va.getName()) != null) ? field.getMsg(va.getName()) : va.getMsg();

    return new ActionMessage(msg, args);
}

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.//  w  w  w .  j a  va 2s  . c  o m
 * <p/>
 */
public static String getMessageKey(ValidatorAction va, Field field) {
    return (field.getMsg(va.getName()) != null ? field.getMsg(va.getName()) : va.getMsg());
}