public class ActionSupport extends Object implements Action, Validateable, ValidationAware, TextProvider, LocaleProvider, Serializable
| Constructor and Description |
|---|
ActionSupport() |
| Modifier and Type | Method and Description |
|---|---|
void |
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 |
clearActionErrors()
Clears action errors.
|
void |
clearErrors()
Clears all errors.
|
void |
clearErrorsAndMessages()
Clears all errors and messages.
|
void |
clearFieldErrors()
Clears field errors.
|
void |
clearMessages()
Clears messages.
|
Object |
clone() |
String |
execute()
A default implementation that does nothing an returns "success".
|
Collection<String> |
getActionErrors()
Get the Collection of Action-level error messages for this action.
|
Collection<String> |
getActionMessages()
Get the Collection of Action-level messages for this action.
|
protected Container |
getContainer()
TODO: This a temporary solution, maybe we should consider stop injecting container into beans
|
Map<String,List<String>> |
getFieldErrors()
Get the field specific errors associated with this action.
|
String |
getFormatted(String key,
String expr)
Dedicated method to support I10N and conversion errors
|
Locale |
getLocale()
Gets the provided locale.
|
protected LocaleProvider |
getLocaleProvider() |
String |
getText(String aTextName)
Gets a message based on a message key or if no message is found the provided key
is returned.
|
String |
getText(String aTextName,
List<?> args)
Gets a message based on a key using the supplied args, as defined in
MessageFormat or the provided key if no message is found. |
String |
getText(String aTextName,
String defaultValue)
Gets a message based on a key, or, if the message is not found, a supplied
default value is returned.
|
String |
getText(String key,
String[] args)
Gets a message based on a key using the supplied args, as defined in
MessageFormat, or the provided key if no message is found. |
String |
getText(String aTextName,
String defaultValue,
List<?> args)
Gets a message based on a key using the supplied args, as defined in
MessageFormat, or, if the message is not found, a supplied
default value is returned. |
String |
getText(String key,
String defaultValue,
List<?> args,
ValueStack stack)
Gets a message based on a key using the supplied args, as defined in
MessageFormat, or, if the message is not found, a supplied
default value is returned. |
String |
getText(String aTextName,
String defaultValue,
String obj)
Gets a message based on a key using the supplied obj, as defined in
MessageFormat, or, if the message is not found, a supplied
default value is returned. |
String |
getText(String key,
String defaultValue,
String[] args)
Gets a message based on a key using the supplied args, as defined in
MessageFormat, or, if the message is not found, a supplied
default value is returned. |
String |
getText(String key,
String defaultValue,
String[] args,
ValueStack stack)
Gets a message based on a key using the supplied args, as defined in
MessageFormat, or, if the message is not found, a supplied
default value is returned. |
protected TextProvider |
getTextProvider()
If called first time it will create
TextProviderFactory,
inject dependency (if Container is accesible) into in,
then will create new TextProvider and store it in a field
for future references and at the returns reference to that field |
ResourceBundle |
getTexts()
Get the resource bundle associated with the implementing class (usually an action).
|
ResourceBundle |
getTexts(String aBundleName)
Get the named bundle, such as "com/acme/Foo".
|
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.
|
boolean |
hasKey(String key)
Checks if a message key exists.
|
String |
input() |
boolean |
isValidLocale(Locale locale)
Validates if provided
Locale is value |
boolean |
isValidLocaleString(String localeStr)
Validates if provided string is a valid
Locale |
void |
pause(String result)
Stops the action invocation immediately (by throwing a PauseException) and causes the action invocation to return
the specified result, such as
Action.SUCCESS, Action.INPUT, etc. |
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 |
setContainer(Container container) |
void |
setFieldErrors(Map<String,List<String>> errorMap)
Set the field error map of fieldname (String) to Collection of String error messages.
|
void |
validate()
A default implementation that validates nothing.
|
protected Container container
public void setActionErrors(Collection<String> errorMessages)
ValidationAwaresetActionErrors in interface ValidationAwareerrorMessages - Collection of String error messagespublic Collection<String> getActionErrors()
ValidationAwaregetActionErrors in interface ValidationAwarepublic void setActionMessages(Collection<String> messages)
ValidationAwaresetActionMessages in interface ValidationAwaremessages - Collection of String messages (not errors).public Collection<String> getActionMessages()
ValidationAwaregetActionMessages in interface ValidationAwarepublic void setFieldErrors(Map<String,List<String>> errorMap)
ValidationAwaresetFieldErrors in interface ValidationAwareerrorMap - field error mappublic Map<String,List<String>> getFieldErrors()
ValidationAwaregetFieldErrors in interface ValidationAwarepublic Locale getLocale()
LocaleProvidergetLocale in interface LocaleProviderpublic boolean isValidLocaleString(String localeStr)
LocaleProviderLocaleisValidLocaleString in interface LocaleProviderlocaleStr - a String representing locale, e.g. en_ENpublic boolean isValidLocale(Locale locale)
LocaleProviderLocale is valueisValidLocale in interface LocaleProviderlocale - instance of Locale to validatepublic boolean hasKey(String key)
TextProviderhasKey in interface TextProviderkey - message key to check forpublic String getText(String aTextName)
TextProvidergetText in interface TextProvideraTextName - the resource bundle key that is to be searched forpublic String getText(String aTextName, String defaultValue)
TextProvidergetText in interface TextProvideraTextName - the resource bundle key that is to be searched fordefaultValue - the default value which will be returned if no message is foundpublic String getText(String aTextName, String defaultValue, String obj)
TextProviderMessageFormat, or, if the message is not found, a supplied
default value is returned.getText in interface TextProvideraTextName - the resource bundle key that is to be searched fordefaultValue - the default value which will be returned if no message is foundobj - obj to be used in a MessageFormat messagepublic String getText(String aTextName, List<?> args)
TextProviderMessageFormat or the provided key if no message is found.getText in interface TextProvideraTextName - the resource bundle key that is to be searched forargs - a list args to be used in a MessageFormat messagepublic String getText(String key, String[] args)
TextProviderMessageFormat, or the provided key if no message is found.getText in interface TextProviderkey - the resource bundle key that is to be searched forargs - an array args to be used in a MessageFormat messagepublic String getText(String aTextName, String defaultValue, List<?> args)
TextProviderMessageFormat, or, if the message is not found, a supplied
default value is returned.getText in interface TextProvideraTextName - the resource bundle key that is to be searched fordefaultValue - the default value which will be returned if no message is foundargs - a list args to be used in a MessageFormat messagepublic String getText(String key, String defaultValue, String[] args)
TextProviderMessageFormat, or, if the message is not found, a supplied
default value is returned.getText in interface TextProviderkey - the resource bundle key that is to be searched fordefaultValue - the default value which will be returned if no message is foundargs - an array args to be used in a MessageFormat messagepublic String getText(String key, String defaultValue, List<?> args, ValueStack stack)
TextProviderMessageFormat, or, if the message is not found, a supplied
default value is returned. Instead of using the value stack in the ActionContext
this version of the getText() method uses the provided value stack.getText in interface TextProviderkey - the resource bundle key that is to be searched fordefaultValue - the default value which will be returned if no message is foundargs - a list args to be used in a MessageFormat messagestack - the value stack to use for finding the textpublic String getText(String key, String defaultValue, String[] args, ValueStack stack)
TextProviderMessageFormat, or, if the message is not found, a supplied
default value is returned. Instead of using the value stack in the ActionContext
this version of the getText() method uses the provided value stack.getText in interface TextProviderkey - the resource bundle key that is to be searched fordefaultValue - the default value which will be returned if no message is foundargs - an array args to be used in a MessageFormat messagestack - the value stack to use for finding the textpublic String getFormatted(String key, String expr)
key - message which contains formatting stringexpr - that should be formattedpublic ResourceBundle getTexts()
TextProvidergetTexts in interface TextProviderpublic ResourceBundle getTexts(String aBundleName)
TextProvidergetTexts in interface TextProvideraBundleName - the name of the resource bundle, such as "com/acme/Foo".public void addActionError(String anErrorMessage)
ValidationAwareaddActionError in interface ValidationAwareanErrorMessage - the error messagepublic void addActionMessage(String aMessage)
ValidationAwareaddActionMessage in interface ValidationAwareaMessage - the messagepublic void addFieldError(String fieldName, String errorMessage)
ValidationAwareaddFieldError in interface ValidationAwarefieldName - name of fielderrorMessage - the error messagepublic String execute() throws Exception
Subclasses should override this method to provide their business logic.
See also Action.execute().
execute in interface ActionAction.SUCCESSException - can be thrown by subclasses.public boolean hasActionErrors()
ValidationAwarehasActionErrors in interface ValidationAwarepublic boolean hasActionMessages()
ValidationAwarehasActionMessages in interface ValidationAwarepublic boolean hasErrors()
ValidationAwarehasErrors in interface ValidationAware(hasActionErrors() || hasFieldErrors())public boolean hasFieldErrors()
ValidationAwarehasFieldErrors in interface ValidationAwarepublic void clearFieldErrors()
public void clearActionErrors()
public void clearMessages()
public void clearErrors()
public void clearErrorsAndMessages()
public void validate()
validate in interface Validateablepublic Object clone() throws CloneNotSupportedException
clone in class ObjectCloneNotSupportedExceptionpublic void pause(String result)
Action.SUCCESS, Action.INPUT, etc.
The next time this action is invoked (and using the same continuation ID), the method will resume immediately after where this method was called, with the entire call stack in the execute method restored.
Note: this method can only be called within the execute() method.
result - the result to return - the same type of return value in the execute() method.protected TextProvider getTextProvider()
TextProviderFactory,
inject dependency (if Container is accesible) into in,
then will create new TextProvider and store it in a field
for future references and at the returns reference to that fieldprotected LocaleProvider getLocaleProvider()
protected Container getContainer()
public void setContainer(Container container)
Copyright © 2000–2018 Apache Software Foundation. All rights reserved.