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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddActionError(String anErrorMessage) Add an Action-level error message to this Action.voidaddActionMessage(String aMessage) Add an Action-level message to this Action.voidaddFieldError(String fieldName, String errorMessage) Add an error message for a given field.voidClears action errors list.voidClears all error list/maps.voidClears all error and messages list/maps.voidClears field errors map.voidClears 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.booleanCheck whether there are any Action-level error messages.booleanChecks whether there are any Action-level messages.booleanChecks whether there are any action errors or field errors.booleanCheck whether there are any field errors associated with this action.voidsetActionErrors(Collection<String> errorMessages) Set the Collection of Action-level String error messages.voidsetActionMessages(Collection<String> messages) Set the Collection of Action-level String messages (not errors).voidsetFieldErrors(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:ValidationAwareSet the Collection of Action-level String error messages.- Specified by:
setActionErrorsin interfaceValidationAware- Parameters:
errorMessages- Collection of String error messages
-
getActionErrors
Description copied from interface:ValidationAwareGet 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:
getActionErrorsin interfaceValidationAware- Returns:
- Collection of String error messages
-
setActionMessages
Description copied from interface:ValidationAwareSet the Collection of Action-level String messages (not errors).- Specified by:
setActionMessagesin interfaceValidationAware- Parameters:
messages- Collection of String messages (not errors).
-
getActionMessages
Description copied from interface:ValidationAwareGet 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:
getActionMessagesin interfaceValidationAware- Returns:
- Collection of String messages
-
setFieldErrors
Description copied from interface:ValidationAwareSet the field error map of fieldname (String) to Collection of String error messages.- Specified by:
setFieldErrorsin interfaceValidationAware- Parameters:
errorMap- field error map
-
getFieldErrors
Description copied from interface:ValidationAwareGet 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:
getFieldErrorsin interfaceValidationAware- Returns:
- Map with errors mapped from fieldname (String) to Collection of String error messages
-
addActionError
Description copied from interface:ValidationAwareAdd an Action-level error message to this Action.- Specified by:
addActionErrorin interfaceValidationAware- Parameters:
anErrorMessage- the error message
-
addActionMessage
Description copied from interface:ValidationAwareAdd an Action-level message to this Action.- Specified by:
addActionMessagein interfaceValidationAware- Parameters:
aMessage- the message
-
addFieldError
Description copied from interface:ValidationAwareAdd an error message for a given field.- Specified by:
addFieldErrorin interfaceValidationAware- Parameters:
fieldName- name of fielderrorMessage- the error message
-
hasActionErrors
public boolean hasActionErrors()Description copied from interface:ValidationAwareCheck whether there are any Action-level error messages.- Specified by:
hasActionErrorsin interfaceValidationAware- Returns:
- true if any Action-level error messages have been registered
-
hasActionMessages
public boolean hasActionMessages()Description copied from interface:ValidationAwareChecks whether there are any Action-level messages.- Specified by:
hasActionMessagesin interfaceValidationAware- Returns:
- true if any Action-level messages have been registered
-
hasErrors
public boolean hasErrors()Description copied from interface:ValidationAwareChecks whether there are any action errors or field errors.- Specified by:
hasErrorsin interfaceValidationAware- Returns:
(hasActionErrors() || hasFieldErrors())
-
hasFieldErrors
public boolean hasFieldErrors()Description copied from interface:ValidationAwareCheck whether there are any field errors associated with this action.- Specified by:
hasFieldErrorsin 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.
-