Class CopyFormToContext
java.lang.Object
org.apache.struts.chain.commands.ActionCommandBase
org.apache.struts.chain.commands.generic.CopyFormToContext
- All Implemented Interfaces:
org.apache.commons.chain.Command<ActionContext>
,ActionCommand
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.
- Version:
- $Id$
-
Field Summary
Fields inherited from interface org.apache.commons.chain.Command
CONTINUE_PROCESSING, PROCESSING_COMPLETE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
execute_
(ActionContext actionContext) Look up anActionForm
instance based on the configured properties of this command and copy it into theContext
.protected ActionForm
findOrCreateForm
(ActionContext context) Based on the properties of this command and the givenActionContext
, find or create anActionForm
instance for preparation.protected ActionForm
findOrCreateForm
(ActionContext ctx, String effectiveFormName, String effectiveScope) Actually find or create an instance ofActionForm
configured under the form-bean-nameeffectiveFormName
, looking in in theActionContext's
scope as identified byeffectiveScope
.ReturnActionPath
property.ReturnFormName
property.getScope()
ReturnScope
property.getToKey()
ReturnToKey
property.void
setActionPath
(String actionPath) SetActionPath
property.void
setFormName
(String formName) SetFormName
propertyvoid
SetScope
property.void
SetToKey
property.Methods inherited from class org.apache.struts.chain.commands.ActionCommandBase
execute
-
Constructor Details
-
CopyFormToContext
public CopyFormToContext()
-
-
Method Details
-
getActionPath
ReturnActionPath
property.- Returns:
- ActionPath property
-
setActionPath
SetActionPath
property.- Parameters:
actionPath
- New value for ActionPath
-
getFormName
ReturnFormName
property.- Returns:
- FormName property
-
setFormName
SetFormName
property- Parameters:
formName
- New value for FormName
-
getScope
ReturnScope
property.- Returns:
- Scope property
-
setScope
SetScope
property.- Parameters:
scope
- New value for Scope
-
getToKey
ReturnToKey
property.- Returns:
- ToKey property
-
setToKey
SetToKey
property.- Parameters:
toKey
- New value for FormName
-
execute_
Look up anActionForm
instance based on the configured properties of this command and copy it into theContext
. After this command successfully executes, anActionForm
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 theActionContext
available for another command to do pre-population of values or other preparation.- Specified by:
execute_
in classActionCommandBase
- Parameters:
actionContext
- Our ActionContext- Returns:
- TRUE if processing should halt
- Throws:
Exception
- on any error
-
findOrCreateForm
protected ActionForm findOrCreateForm(ActionContext context) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, ClassNotFoundException Based on the properties of this command and the givenActionContext
, find or create anActionForm
instance for preparation.- Parameters:
context
- ActionContextBase class that we are processing- Returns:
- ActionForm instance
- Throws:
InstantiationException
- If ActionContext is not subclass of ActionContextBaseIllegalAccessException
- On failed instantiationIllegalArgumentException
- On ActionConfig not foundInvocationTargetException
- if the underlying constructor throws an exceptionNoSuchMethodException
- if a matching method is not foundSecurityException
- if there is a security-exceptionClassNotFoundException
- if the specified class cannot be loaded
-
findOrCreateForm
protected ActionForm findOrCreateForm(ActionContext ctx, String effectiveFormName, String effectiveScope) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, ClassNotFoundException Actually find or create an instance ofActionForm
configured under the form-bean-nameeffectiveFormName
, looking in in theActionContext's
scope as identified byeffectiveScope
. 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 ofActionContextBase
, which implements the utility methodfindOrCreateActionForm
.- Parameters:
ctx
- The ActionContext we are processingeffectiveFormName
- the target form nameeffectiveScope
- The target scope- Returns:
- ActionForm instance, storing in scope if created
- Throws:
InstantiationException
- If ActionContext is not subclass of ActionContextBase or object cannot be createdIllegalAccessException
- On failed instantiationIllegalArgumentException
- On form not found in scopeInvocationTargetException
- if the underlying constructor throws an exceptionNoSuchMethodException
- if a matching method is not foundSecurityException
- if there is a security-exceptionClassNotFoundException
- if the specified class cannot be loaded
-