|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.opensymphony.xwork2.ActionSupport
public class ActionSupport
Provides a default implementation for the most common actions. See the documentation for all the interfaces this class implements for more detailed information.
Field Summary | |
---|---|
protected static Logger |
LOG
|
private TextProvider |
textProvider
|
private ValidationAwareSupport |
validationAware
|
Fields inherited from interface com.opensymphony.xwork2.Action |
---|
ERROR, INPUT, LOGIN, NONE, SUCCESS |
Constructor Summary | |
---|---|
ActionSupport()
|
Method Summary | |
---|---|
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 |
doDefault()
|
String |
execute()
A default implementation that does nothing an returns "success". |
Collection |
getActionErrors()
Get the Collection of Action-level error messages for this action. |
Collection |
getActionMessages()
Get the Collection of Action-level messages for this action. |
Collection |
getErrorMessages()
Deprecated. Use getActionErrors() . |
Map |
getErrors()
Deprecated. Use getFieldErrors() . |
Map |
getFieldErrors()
Get the field specific errors associated with this action. |
Locale |
getLocale()
Gets the provided locale. |
String |
getText(String aTextName)
Gets a message based on a message key, or null if no message is found. |
String |
getText(String aTextName,
List args)
Gets a message based on a key using the supplied args, as defined in MessageFormat , or null 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 null 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. |
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. |
String |
input()
|
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 errorMessages)
Set the Collection of Action-level String error messages. |
void |
setActionMessages(Collection messages)
Set the Collection of Action-level String messages (not errors). |
void |
setFieldErrors(Map errorMap)
Set the field error map of fieldname (String) to Collection of String error messages. |
void |
validate()
A default implementation that validates nothing. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static Logger LOG
private final transient TextProvider textProvider
private final ValidationAwareSupport validationAware
Constructor Detail |
---|
public ActionSupport()
Method Detail |
---|
public void setActionErrors(Collection errorMessages)
ValidationAware
setActionErrors
in interface ValidationAware
errorMessages
- Collection of String error messagespublic Collection getActionErrors()
ValidationAware
getActionErrors
in interface ValidationAware
public void setActionMessages(Collection messages)
ValidationAware
setActionMessages
in interface ValidationAware
messages
- Collection of String messages (not errors).public Collection getActionMessages()
ValidationAware
getActionMessages
in interface ValidationAware
public Collection getErrorMessages()
getActionErrors()
.
public Map getErrors()
getFieldErrors()
.
public void setFieldErrors(Map errorMap)
ValidationAware
setFieldErrors
in interface ValidationAware
errorMap
- field error mappublic Map getFieldErrors()
ValidationAware
getFieldErrors
in interface ValidationAware
public Locale getLocale()
LocaleProvider
getLocale
in interface LocaleProvider
public String getText(String aTextName)
TextProvider
getText
in interface TextProvider
aTextName
- the resource bundle key that is to be searched for
public String getText(String aTextName, String defaultValue)
TextProvider
getText
in interface TextProvider
aTextName
- the resource bundle key that is to be searched fordefaultValue
- the default value which will be returned if no message is found
public String getText(String aTextName, String defaultValue, String obj)
TextProvider
MessageFormat
, or, if the message is not found, a supplied
default value is returned.
getText
in interface TextProvider
aTextName
- 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
message
public String getText(String aTextName, List args)
TextProvider
MessageFormat
, or null if no message is found.
getText
in interface TextProvider
aTextName
- the resource bundle key that is to be searched forargs
- a list args to be used in a MessageFormat
message
public String getText(String key, String[] args)
TextProvider
MessageFormat
, or null if no message is found.
getText
in interface TextProvider
key
- the resource bundle key that is to be searched forargs
- an array args to be used in a MessageFormat
message
public String getText(String aTextName, String defaultValue, List args)
TextProvider
MessageFormat
, or, if the message is not found, a supplied
default value is returned.
getText
in interface TextProvider
aTextName
- 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
message
public String getText(String key, String defaultValue, String[] args)
TextProvider
MessageFormat
, or, if the message is not found, a supplied
default value is returned.
getText
in interface TextProvider
key
- 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
message
public String getText(String key, String defaultValue, List args, ValueStack stack)
TextProvider
MessageFormat
, 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 TextProvider
key
- 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 text
public String getText(String key, String defaultValue, String[] args, ValueStack stack)
TextProvider
MessageFormat
, 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 TextProvider
key
- 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 text
public ResourceBundle getTexts()
TextProvider
getTexts
in interface TextProvider
public ResourceBundle getTexts(String aBundleName)
TextProvider
getTexts
in interface TextProvider
aBundleName
- the name of the resource bundle, such as "com/acme/Foo"
.
public void addActionError(String anErrorMessage)
ValidationAware
addActionError
in interface ValidationAware
anErrorMessage
- the error messagepublic void addActionMessage(String aMessage)
ValidationAware
addActionMessage
in interface ValidationAware
aMessage
- the messagepublic void addFieldError(String fieldName, String errorMessage)
ValidationAware
addFieldError
in interface ValidationAware
fieldName
- name of fielderrorMessage
- the error messagepublic String input() throws Exception
Exception
public String doDefault() throws Exception
Exception
public String execute() throws Exception
Action.execute()
.
execute
in interface Action
Action.SUCCESS
Exception
- can be thrown by subclasses.public boolean hasActionErrors()
ValidationAware
hasActionErrors
in interface ValidationAware
public boolean hasActionMessages()
ValidationAware
hasActionMessages
in interface ValidationAware
public boolean hasErrors()
ValidationAware
hasErrors
in interface ValidationAware
(hasActionErrors() || hasFieldErrors())
public boolean hasFieldErrors()
ValidationAware
hasFieldErrors
in interface ValidationAware
public void clearFieldErrors()
public void clearActionErrors()
public void clearMessages()
public void clearErrors()
public void clearErrorsAndMessages()
public void validate()
validate
in interface Validateable
public Object clone() throws CloneNotSupportedException
clone
in class Object
CloneNotSupportedException
public 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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |