Package org.apache.struts2
Class ValidationAwareSupport
java.lang.Object
org.apache.struts2.ValidationAwareSupport
- All Implemented Interfaces:
Serializable
,ValidationAware
Provides a default implementation of ValidationAware. Returns new collections for
errors and messages (defensive copy).
- Version:
- $Date$ $Id$
- Author:
- Jason Carreira, tm_jee
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addActionError
(String anErrorMessage) Add an Action-level error message to this Action.void
addActionMessage
(String aMessage) Add an Action-level message to this Action.void
addFieldError
(String fieldName, String errorMessage) Add an error message for a given field.void
Clears action errors list.void
Clears all error list/maps.void
Clears all error and messages list/maps.void
Clears field errors map.void
Clears messages list.Get the Collection of Action-level error messages for this action.Get the Collection of Action-level messages for this action.Get the field specific errors associated with this action.boolean
Check whether there are any Action-level error messages.boolean
Checks whether there are any Action-level messages.boolean
Checks whether there are any action errors or field errors.boolean
Check whether there are any field errors associated with this action.void
setActionErrors
(Collection<String> errorMessages) Set the Collection of Action-level String error messages.void
setActionMessages
(Collection<String> messages) Set the Collection of Action-level String messages (not errors).void
setFieldErrors
(Map<String, List<String>> errorMap) Set the field error map of fieldname (String) to Collection of String error messages.
-
Constructor Details
-
ValidationAwareSupport
public ValidationAwareSupport()
-
-
Method Details
-
setActionErrors
Description copied from interface:ValidationAware
Set the Collection of Action-level String error messages.- Specified by:
setActionErrors
in interfaceValidationAware
- Parameters:
errorMessages
- Collection of String error messages
-
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 interfaceValidationAware
- Returns:
- Collection of String error messages
-
setActionMessages
Description copied from interface:ValidationAware
Set the Collection of Action-level String messages (not errors).- Specified by:
setActionMessages
in interfaceValidationAware
- Parameters:
messages
- Collection of String messages (not errors).
-
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 interfaceValidationAware
- Returns:
- Collection of String messages
-
setFieldErrors
Description copied from interface:ValidationAware
Set the field error map of fieldname (String) to Collection of String error messages.- Specified by:
setFieldErrors
in interfaceValidationAware
- Parameters:
errorMap
- field error map
-
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 interfaceValidationAware
- Returns:
- Map with errors mapped from fieldname (String) to Collection of String error messages
-
addActionError
Description copied from interface:ValidationAware
Add an Action-level error message to this Action.- Specified by:
addActionError
in interfaceValidationAware
- Parameters:
anErrorMessage
- the error message
-
addActionMessage
Description copied from interface:ValidationAware
Add an Action-level message to this Action.- Specified by:
addActionMessage
in interfaceValidationAware
- Parameters:
aMessage
- the message
-
addFieldError
Description copied from interface:ValidationAware
Add an error message for a given field.- Specified by:
addFieldError
in interfaceValidationAware
- Parameters:
fieldName
- name of fielderrorMessage
- 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 interfaceValidationAware
- 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 interfaceValidationAware
- 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.- Specified by:
hasErrors
in interfaceValidationAware
- 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 interfaceValidationAware
- 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.
-