public class CopyFormToContext extends ActionCommandBase
Subclass this command and configure it as part of a per-forward chain to perform any necessary pre-population or other preparation for a form before control is dispatched to the view layer.
Constructor and Description |
---|
CopyFormToContext() |
Modifier and Type | Method and Description |
---|---|
boolean |
execute(ActionContext actionContext)
Look up an ActionForm instance based on the configured properties of
this command and copy it into the
Context . |
protected ActionForm |
findOrCreateForm(ActionContext context)
Based on the properties of this command and the given
ActionContext , find or create an ActionForm instance for
preparation. |
protected ActionForm |
findOrCreateForm(ActionContext ctx,
String effectiveFormName,
String effectiveScope)
Actually find or create an instance of ActionForm configured under
the form-bean-name
effectiveFormName , looking in in the
ActionContext's scope as identified by
effectiveScope . |
String |
getActionPath()
Return ActionPath property.
|
String |
getFormName()
Return FormName property.
|
String |
getScope()
Return Scope property.
|
String |
getToKey()
Return ToKey property.
|
void |
setActionPath(String actionPath)
Set ActionPath property.
|
void |
setFormName(String formName)
Set FormName property.
|
void |
setScope(String scope)
Set Scope property.
|
void |
setToKey(String toKey)
Set ToKey property.
|
execute
public String getActionPath()
Return ActionPath property.
public void setActionPath(String actionPath)
Set ActionPath property.
actionPath
- New valuefor ActionPathpublic String getFormName()
Return FormName property.
public void setFormName(String formName)
Set FormName property.
formName
- New valuefor FormNamepublic String getScope()
Return Scope property.
public void setScope(String scope)
Set Scope property.
scope
- New valuefor Scopepublic String getToKey()
Return ToKey property.
public void setToKey(String toKey)
Set ToKey property.
toKey
- New valuefor FormNamepublic boolean execute(ActionContext actionContext) throws Exception
Look up an ActionForm instance based on the configured properties of
this command and copy it into the Context
. After this
command successfully executes, an ActionForm instance will exist in the
specified scope and will be available, for example for backing fields
in an HTML form. It will also be in the ActionContext
available for another command to do prepopulation of values or other
preparation.
execute
in interface ActionCommand
execute
in class ActionCommandBase
actionContext
- Our ActionContextException
- on any errorprotected ActionForm findOrCreateForm(ActionContext context) throws IllegalAccessException, InstantiationException
Based on the properties of this command and the given
ActionContext
, find or create an ActionForm instance for
preparation.
context
- ActionContextBase class that we are processingIllegalArgumentException
- On ActionConfig not foundIllegalStateException
- On undefined scope and formbeanIllegalAccessException
- On failed instantiationInstantiationException
- If ActionContext is not subsclass of
ActionContextBaseprotected ActionForm findOrCreateForm(ActionContext ctx, String effectiveFormName, String effectiveScope) throws IllegalAccessException, InstantiationException
Actually find or create an instance of ActionForm configured under
the form-bean-name effectiveFormName
, looking in in the
ActionContext's
scope as identified by
effectiveScope
. If a form is created, it will also be
stored in that scope.
NOTE: This specific method depends on the instance of
ActionContext
which is passed being a subclass of
ActionContextBase
, which implements the utility method
findOrCreateActionForm
.
ctx
- The ActionContext we are processingeffectiveFormName
- the target form nameeffectiveScope
- The target scopeInstantiationException
- If ActionContext is not subsclass of
ActionContextBaseInstantiationException
- If object cannot be createdIllegalArgumentException
- On form not found in/ scopeIllegalAccessException
- On failed instantiationIllegalStateException
- If ActionContext is not a subclass of
ActionBaseCopyright © 2000–2016 Apache Software Foundation. All rights reserved.