com.opensymphony.xwork2
Class ValidationAwareSupport

java.lang.Object
  extended by com.opensymphony.xwork2.ValidationAwareSupport
All Implemented Interfaces:
ValidationAware, java.io.Serializable

public class ValidationAwareSupport
extends java.lang.Object
implements ValidationAware, java.io.Serializable

Provides a default implementation of ValidationAware. Returns new collections for errors and messages (defensive copy).

Version:
$Date: 2009-12-27 19:18:29 +0100 (Sun, 27 Dec 2009) $ $Id: ValidationAwareSupport.java 894090 2009-12-27 18:18:29Z martinc $
Author:
Jason Carreira, tm_jee
See Also:
Serialized Form

Constructor Summary
ValidationAwareSupport()
           
 
Method Summary
 void addActionError(java.lang.String anErrorMessage)
          Add an Action-level error message to this Action.
 void addActionMessage(java.lang.String aMessage)
          Add an Action-level message to this Action.
 void addFieldError(java.lang.String fieldName, java.lang.String errorMessage)
          Add an error message for a given field.
 void clearActionErrors()
          Clears action errors list.
 void clearErrors()
          Clears all error list/maps.
 void clearErrorsAndMessages()
          Clears all error and messages list/maps.
 void clearFieldErrors()
          Clears field errors map.
 void clearMessages()
          Clears messages list.
 java.util.Collection<java.lang.String> getActionErrors()
          Get the Collection of Action-level error messages for this action.
 java.util.Collection<java.lang.String> getActionMessages()
          Get the Collection of Action-level messages for this action.
 java.util.Map<java.lang.String,java.util.List<java.lang.String>> getFieldErrors()
          Get the field specific errors associated with this action.
 boolean hasActionErrors()
          Check whether there are any Action-level error messages.
 boolean hasActionMessages()
          Checks whether there are any Action-level messages.
 boolean hasErrors()
          Checks whether there are any action errors or field errors.
 boolean hasFieldErrors()
          Check whether there are any field errors associated with this action.
 void setActionErrors(java.util.Collection<java.lang.String> errorMessages)
          Set the Collection of Action-level String error messages.
 void setActionMessages(java.util.Collection<java.lang.String> messages)
          Set the Collection of Action-level String messages (not errors).
 void setFieldErrors(java.util.Map<java.lang.String,java.util.List<java.lang.String>> errorMap)
          Set the field error map of fieldname (String) to Collection of String error messages.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValidationAwareSupport

public ValidationAwareSupport()
Method Detail

setActionErrors

public void setActionErrors(java.util.Collection<java.lang.String> errorMessages)
Description copied from interface: ValidationAware
Set the Collection of Action-level String error messages.

Specified by:
setActionErrors in interface ValidationAware
Parameters:
errorMessages - Collection of String error messages

getActionErrors

public java.util.Collection<java.lang.String> getActionErrors()
Description copied from interface: ValidationAware
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.

Specified by:
getActionErrors in interface ValidationAware
Returns:
Collection of String error messages

setActionMessages

public void setActionMessages(java.util.Collection<java.lang.String> messages)
Description copied from interface: ValidationAware
Set the Collection of Action-level String messages (not errors).

Specified by:
setActionMessages in interface ValidationAware
Parameters:
messages - Collection of String messages (not errors).

getActionMessages

public java.util.Collection<java.lang.String> getActionMessages()
Description copied from interface: ValidationAware
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.

Specified by:
getActionMessages in interface ValidationAware
Returns:
Collection of String messages

setFieldErrors

public void setFieldErrors(java.util.Map<java.lang.String,java.util.List<java.lang.String>> errorMap)
Description copied from interface: ValidationAware
Set the field error map of fieldname (String) to Collection of String error messages.

Specified by:
setFieldErrors in interface ValidationAware
Parameters:
errorMap - field error map

getFieldErrors

public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getFieldErrors()
Description copied from interface: ValidationAware
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.

Specified by:
getFieldErrors in interface ValidationAware
Returns:
Map with errors mapped from fieldname (String) to Collection of String error messages

addActionError

public void addActionError(java.lang.String anErrorMessage)
Description copied from interface: ValidationAware
Add an Action-level error message to this Action.

Specified by:
addActionError in interface ValidationAware
Parameters:
anErrorMessage - the error message

addActionMessage

public void addActionMessage(java.lang.String aMessage)
Description copied from interface: ValidationAware
Add an Action-level message to this Action.

Specified by:
addActionMessage in interface ValidationAware
Parameters:
aMessage - the message

addFieldError

public void addFieldError(java.lang.String fieldName,
                          java.lang.String errorMessage)
Description copied from interface: ValidationAware
Add an error message for a given field.

Specified by:
addFieldError in interface ValidationAware
Parameters:
fieldName - name of field
errorMessage - the error message

hasActionErrors

public boolean hasActionErrors()
Description copied from interface: ValidationAware
Check whether there are any Action-level error messages.

Specified by:
hasActionErrors in interface ValidationAware
Returns:
true if any Action-level error messages have been registered

hasActionMessages

public boolean hasActionMessages()
Description copied from interface: ValidationAware
Checks whether there are any Action-level messages.

Specified by:
hasActionMessages in interface ValidationAware
Returns:
true if any Action-level messages have been registered

hasErrors

public boolean hasErrors()
Description copied from interface: ValidationAware
Checks whether there are any action errors or field errors.

Note: that this does not have the same meaning as in WW 1.x.

Specified by:
hasErrors in interface ValidationAware
Returns:
(hasActionErrors() || hasFieldErrors())

hasFieldErrors

public boolean hasFieldErrors()
Description copied from interface: ValidationAware
Check whether there are any field errors associated with this action.

Specified by:
hasFieldErrors in interface ValidationAware
Returns:
whether there are any field errors

clearFieldErrors

public void clearFieldErrors()
Clears field errors map.

Will clear the map that contains field errors.


clearActionErrors

public void clearActionErrors()
Clears action errors list.

Will clear the list that contains action errors.


clearMessages

public void clearMessages()
Clears messages list.

Will clear the list that contains action messages.


clearErrors

public void clearErrors()
Clears all error list/maps.

Will clear the map and list that contain field errors and action errors.


clearErrorsAndMessages

public void clearErrorsAndMessages()
Clears all error and messages list/maps.

Will clear the maps/lists that contain field errors, action errors and action messages.



Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.