Commits

Anonymous committed c71ee98

Fixed WW-649: field error ordering.

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@382e221344d-f017-0410-9bd5-d282ab1896d7

Comments (0)

Files changed (1)

src/java/com/opensymphony/xwork/ValidationAwareSupport.java

 
 
 /**
- * Provides a default implementation of ValidationAware.
+ * Provides a default implementation of ValidationAware. Returns new collections for
+ * errors and messages (defensive copy).
  *
  * @author Jason Carreira
  */
         this.fieldErrors = errorMap;
     }
 
-    /**
-     * Get the field specific errors.
-     *
-     * @return an unmodifiable Map with errors mapped from fieldname (String) to Collection of
-     * String error messages
-     */
     public synchronized Map getFieldErrors() {
-        return new HashMap(internalGetFieldErrors());
+        return new LinkedHashMap(internalGetFieldErrors());
     }
 
     public synchronized void addActionError(String anErrorMessage) {
         internalGetActionErrors().add(anErrorMessage);
     }
 
-    /**
-     * Add an Action level message to this Action
-     */
     public void addActionMessage(String aMessage) {
         internalGetActionMessages().add(aMessage);
     }
         return (actionErrors != null) && !actionErrors.isEmpty();
     }
 
-    /**
-     * Checks whether there are any Action-level messages.
-     *
-     * @return true if any Action-level messages have been registered
-     */
     public boolean hasActionMessages() {
         return (actionMessages != null) && !actionMessages.isEmpty();
     }
 
-    /**
-     * Note that this does not have the same meaning as in WW 1.x
-     * @return (hasActionErrors() || hasFieldErrors())
-     */
     public synchronized boolean hasErrors() {
         return (hasActionErrors() || hasFieldErrors());
     }
 
     private Map internalGetFieldErrors() {
         if (fieldErrors == null) {
-            fieldErrors = new HashMap();
+            fieldErrors = new LinkedHashMap();
         }
 
         return fieldErrors;