dgraham     2003/08/15 16:53:11

  Modified:    src/share/org/apache/struts/validator Resources.java
  Log:
  Added getActionMessage() method to replace getActionError() as
  ActionError is now deprecated.
  
  Revision  Changes    Path
  1.21      +35 -4     
jakarta-struts/src/share/org/apache/struts/validator/Resources.java
  
  Index: Resources.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/validator/Resources.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- Resources.java    15 Aug 2003 23:50:26 -0000      1.20
  +++ Resources.java    15 Aug 2003 23:53:11 -0000      1.21
  @@ -73,6 +73,7 @@
   import org.apache.struts.Globals;
   import org.apache.struts.action.ActionError;
   import org.apache.struts.action.ActionErrors;
  +import org.apache.struts.action.ActionMessage;
   import org.apache.struts.util.MessageResources;
   import org.apache.struts.util.ModuleUtils;
   import org.apache.struts.util.RequestUtils;
  @@ -221,6 +222,8 @@
        * @param request the servlet request
        * @param va Validator action
        * @param field the validator Field
  +     * @deprecated Use getActionMessage() instead.  This will be removed after
  +     * Struts 1.2.
        */
       public static ActionError getActionError(
           HttpServletRequest request,
  @@ -240,6 +243,34 @@
                   : va.getMsg();
   
           return new ActionError(msg, args);
  +    }
  +    
  +    /**
  +     * Gets the <code>ActionError</code> based on the 
  +     * <code>ValidatorAction</code> message and the <code>Field</code>'s 
  +     * arg objects.
  +     * @param request the servlet request
  +     * @param va Validator action
  +     * @param field the validator Field
  +     */
  +    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);
       }
   
       /**
  
  
  

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

Reply via email to