Home » xwork-2.1.5 » com.opensymphony » xwork2 » [javadoc | source]

    1   /*
    2    * Copyright (c) 2002-2007 by OpenSymphony
    3    * All rights reserved.
    4    */
    5   package com.opensymphony.xwork2;
    6   
    7   import java.util.Collection;
    8   import java.util.List;
    9   import java.util.Map;
   10   
   11   /**
   12    * ValidationAware classes can accept Action (class level) or field level error messages. Action level messages are kept
   13    * in a Collection. Field level error messages are kept in a Map from String field name to a List of field error msgs.
   14    *
   15    * @author plightbo 
   16    */
   17   public interface ValidationAware {
   18   
   19       /**
   20        * Set the Collection of Action-level String error messages.
   21        *
   22        * @param errorMessages Collection of String error messages
   23        */
   24       void setActionErrors(Collection<String> errorMessages);
   25   
   26       /**
   27        * Get the Collection of Action-level error messages for this action. Error messages should not
   28        * be added directly here, as implementations are free to return a new Collection or an
   29        * Unmodifiable Collection.
   30        *
   31        * @return Collection of String error messages
   32        */
   33       Collection<String> getActionErrors();
   34   
   35       /**
   36        * Set the Collection of Action-level String messages (not errors).
   37        *
   38        * @param messages Collection of String messages (not errors).
   39        */
   40       void setActionMessages(Collection<String> messages);
   41   
   42       /**
   43        * Get the Collection of Action-level messages for this action. Messages should not be added
   44        * directly here, as implementations are free to return a new Collection or an Unmodifiable
   45        * Collection.
   46        *
   47        * @return Collection of String messages
   48        */
   49       Collection<String> getActionMessages();
   50   
   51       /**
   52        * Set the field error map of fieldname (String) to Collection of String error messages.
   53        *
   54        * @param errorMap field error map
   55        */
   56       void setFieldErrors(Map<String, List<String>> errorMap);
   57   
   58       /**
   59        * Get the field specific errors associated with this action. Error messages should not be added
   60        * directly here, as implementations are free to return a new Collection or an Unmodifiable
   61        * Collection.
   62        *
   63        * @return Map with errors mapped from fieldname (String) to Collection of String error messages
   64        */
   65       Map<String, List<String>> getFieldErrors();
   66   
   67       /**
   68        * Add an Action-level error message to this Action.
   69        *
   70        * @param anErrorMessage  the error message
   71        */
   72       void addActionError(String anErrorMessage);
   73   
   74       /**
   75        * Add an Action-level message to this Action.
   76        *
   77        * @param aMessage  the message
   78        */
   79       void addActionMessage(String aMessage);
   80   
   81       /**
   82        * Add an error message for a given field.
   83        *
   84        * @param fieldName    name of field
   85        * @param errorMessage the error message
   86        */
   87       void addFieldError(String fieldName, String errorMessage);
   88   
   89       /**
   90        * Check whether there are any Action-level error messages.
   91        *
   92        * @return true if any Action-level error messages have been registered
   93        */
   94       boolean hasActionErrors();
   95   
   96       /**
   97        * Checks whether there are any Action-level messages.
   98        *
   99        * @return true if any Action-level messages have been registered
  100        */
  101       boolean hasActionMessages();
  102   
  103       /**
  104        * Checks whether there are any action errors or field errors.
  105        * <p/>
  106        * <b>Note</b>: that this does not have the same meaning as in WW 1.x.
  107        *
  108        * @return <code>(hasActionErrors() || hasFieldErrors())</code>
  109        */
  110       boolean hasErrors();
  111   
  112       /**
  113        * Check whether there are any field errors associated with this action.
  114        *
  115        * @return whether there are any field errors
  116        */
  117       boolean hasFieldErrors();
  118   
  119   }

Home » xwork-2.1.5 » com.opensymphony » xwork2 » [javadoc | source]