Commits

Anonymous committed a3d14aa

Fix for XW-181 (add ValidationAware.hasActionMessages()).

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

Comments (0)

Files changed (4)

src/java/com/opensymphony/xwork/ActionSupport.java

         return validationAware.hasActionErrors();
     }
 
+    /**
+     * Checks whether there are any Action-level messages.
+     *
+     * @return true if any Action-level messages have been registered
+     */
+    public boolean hasActionMessages() {
+        return validationAware.hasActionMessages();
+    }
+
     public boolean hasErrors() {
         return validationAware.hasErrors();
     }

src/java/com/opensymphony/xwork/ValidationAware.java

     //~ Methods ////////////////////////////////////////////////////////////////
 
     /**
-     * Set the Collection of Action level String error messages
+     * Set the Collection of Action-level String error messages
      *
      * @param errorMessages
      */
     void setActionErrors(Collection errorMessages);
 
     /**
-     * Get the Collection of Action level error messages for this action. Error messages should not be added directly
-     * here, as implementations are free to return a new Collection or an Unmodifiable Collection.
+     * Get the Collection of Action-level error messages for this action. Error messages should not
+     * be added directly here, as implementations are free to return a new Collection or an
+     * Unmodifiable Collection.
      *
      * @return Collection of String error messages
      */
     Collection getActionErrors();
 
     /**
-     * Set the Collection of Action level String messages (not errors)
+     * Set the Collection of Action-level String messages (not errors).
      */
     void setActionMessages(Collection messages);
 
     /**
-     * Get the Collection of Action level messages for this action. Messages should not be added directly
-     * here, as implementations are free to return a new Collection or an Unmodifiable Collection.
+     * Get the Collection of Action-level messages for this action. Messages should not be added
+     * directly here, as implementations are free to return a new Collection or an Unmodifiable
+     * Collection.
      *
      * @return Collection of String messages
      */
     void setFieldErrors(Map errorMap);
 
     /**
-     * Get the field specific errors associated with this action. Error messages should not be added directly
-     * here, as implementations are free to return a new Collection or an Unmodifiable Collection.
+     * Get the field specific errors associated with this action. Error messages should not be added
+     * directly here, as implementations are free to return a new Collection or an Unmodifiable
+     * Collection.
      *
      * @return Map with errors mapped from fieldname (String) to Collection of String error messages
      */
     Map getFieldErrors();
 
     /**
-     * Add an Action level error message to this Action
+     * Add an Action-level error message to this Action
      *
      * @param anErrorMessage
      */
     void addActionError(String anErrorMessage);
 
     /**
-     * Add an Action level message to this Action
+     * Add an Action-level message to this Action
      */
     void addActionMessage(String aMessage);
 
     void addFieldError(String fieldName, String errorMessage);
 
     /**
-     * Check whether there are any Action level error messages
+     * Check whether there are any Action-level error messages
      *
-     * @return true if any Action level error messages have been registered
+     * @return true if any Action-level error messages have been registered
      */
     boolean hasActionErrors();
 
     /**
+     * Checks whether there are any Action-level messages.
+     *
+     * @return true if any Action-level messages have been registered
+     */
+    boolean hasActionMessages();
+
+    /**
      * @return (hasActionErrors() || hasFieldErrors())
      */
     boolean hasErrors();

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

 
 
 /**
- * ValidationAwareSupport
+ * Provides a default implementation of ValidationAware.
+ *
  * @author Jason Carreira
- * Created Aug 2, 2003 11:56:27 PM
  */
 public class ValidationAwareSupport implements ValidationAware {
     //~ Instance fields ////////////////////////////////////////////////////////
     }
 
     /**
-* Get the field specific errors.
-*
-* @return an unmodifiable Map with errors mapped from fieldname (String) to Collection of String error messages
-*/
+     * 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());
     }
     }
 
     /**
- * Add an Action level message to this Action
- */
+     * Add an Action level message to this Action
+     */
     public void addActionMessage(String aMessage) {
         internalGetActionMessages().add(aMessage);
     }
     }
 
     /**
-* Note that this does not have the same meaning as in WW 1.x
-* @return (hasActionErrors() || hasFieldErrors())
-*/
+     * 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());
     }

src/java/com/opensymphony/xwork/validator/DelegatingValidatorContext.java

 
 
 /**
- * DelegatingValidatorContext
+ * Provides a default implementation of ValidatorContext.
+ *
  * @author Jason Carreira
- * Created Aug 3, 2003 12:33:30 AM
  */
 public class DelegatingValidatorContext implements ValidatorContext {
     //~ Instance fields ////////////////////////////////////////////////////////
     }
 
     /**
- * Set the Collection of Action level String messages (not errors)
- */
+     * Set the Collection of Action level String messages (not errors)
+     */
     public void setActionMessages(Collection messages) {
         validationAware.setActionMessages(messages);
     }
 
     /**
- * Get the Collection of Action level messages for this action. Messages should not be added directly
- * here, as implementations are free to return a new Collection or an Unmodifiable Collection.
- *
- * @return Collection of String messages
- */
+     * Get the Collection of Action level messages for this action. Messages should not be added
+     * directly here, as implementations are free to return a new Collection or an Unmodifiable
+     * Collection.
+     *
+     * @return Collection of String messages
+     */
     public Collection getActionMessages() {
         return validationAware.getActionMessages();
     }
     }
 
     /**
-* Translates a simple field name into a full field name in Ognl syntax
-* @param fieldName
-* @return
-*/
+     * Translates a simple field name into a full field name in Ognl syntax
+     * @param fieldName
+     * @return
+     */
     public String getFullFieldName(String fieldName) {
         return fieldName;
     }
     }
 
     /**
- * Add an Action level message to this Action
- */
+     * Add an Action level message to this Action
+     */
     public void addActionMessage(String aMessage) {
         validationAware.addActionMessage(aMessage);
     }
         return validationAware.hasActionErrors();
     }
 
+    /**
+     * Checks whether there are any Action-level messages.
+     *
+     * @return true if any Action-level messages have been registered
+     */
+    public boolean hasActionMessages() {
+        return validationAware.hasActionMessages();
+    }
+
     public boolean hasErrors() {
         return validationAware.hasErrors();
     }
         }
 
         /**
- * Set the Collection of Action level String messages (not errors)
- */
+         * Set the Collection of Action level String messages (not errors)
+         */
         public void setActionMessages(Collection messages) {
             for (Iterator iterator = messages.iterator(); iterator.hasNext();) {
                 String s = (String) iterator.next();
         }
 
         /**
- * Get the Collection of Action level messages for this action. Messages should not be added directly
- * here, as implementations are free to return a new Collection or an Unmodifiable Collection.
- *
- * @return Collection of String messages
- */
+         * Get the Collection of Action level messages for this action. Messages should not be added
+         * directly here, as implementations are free to return a new Collection or an Unmodifiable
+         * Collection.
+         *
+         * @return Collection of String messages
+         */
         public Collection getActionMessages() {
             return null;
         }
         }
 
         /**
- * Add an Action level message to this Action
- */
+         * Add an Action level message to this Action
+         */
         public void addActionMessage(String aMessage) {
             log.info("Validation Message: " + aMessage);
         }
             return false;
         }
 
+        /**
+         * Checks whether there are any Action-level messages.
+         *
+         * @return true if any Action-level messages have been registered
+         */
+        public boolean hasActionMessages() {
+            return false;
+        }
+
         public boolean hasErrors() {
             return false;
         }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.