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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanexecute_(ActionContext actionContext) Look up anActionForminstance based on the configured properties of this command and copy it into theContext.protected ActionFormfindOrCreateForm(ActionContext context) Based on the properties of this command and the givenActionContext, find or create anActionForminstance for preparation.protected ActionFormfindOrCreateForm(ActionContext ctx, String effectiveFormName, String effectiveScope) Actually find or create an instance ofActionFormconfigured under the form-bean-nameeffectiveFormName, looking in in theActionContext'sscope as identified byeffectiveScope.ReturnActionPathproperty.ReturnFormNameproperty.getScope()ReturnScopeproperty.getToKey()ReturnToKeyproperty.voidsetActionPath(String actionPath) SetActionPathproperty.voidsetFormName(String formName) SetFormNamepropertyvoidSetScopeproperty.voidSetToKeyproperty.Methods inherited from class org.apache.struts.chain.commands.ActionCommandBase
execute
-
Constructor Details
-
CopyFormToContext
public CopyFormToContext()
-
-
Method Details
-
getActionPath
ReturnActionPathproperty.- Returns:
- ActionPath property
-
setActionPath
SetActionPathproperty.- Parameters:
actionPath- New value for ActionPath
-
getFormName
ReturnFormNameproperty.- Returns:
- FormName property
-
setFormName
SetFormNameproperty- Parameters:
formName- New value for FormName
-
getScope
ReturnScopeproperty.- Returns:
- Scope property
-
setScope
SetScopeproperty.- Parameters:
scope- New value for Scope
-
getToKey
ReturnToKeyproperty.- Returns:
- ToKey property
-
setToKey
SetToKeyproperty.- Parameters:
toKey- New value for FormName
-
execute_
Look up anActionForminstance based on the configured properties of this command and copy it into theContext. After this command successfully executes, anActionForminstance will exist in the specified scope and will be available, for example for backing fields in an HTML form. It will also be in theActionContextavailable 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 anActionForminstance 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 ofActionFormconfigured under the form-bean-nameeffectiveFormName, looking in in theActionContext'sscope 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
ActionContextwhich 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
-