org.apache.struts.chain.commands.generic
Class CopyFormToContext

java.lang.Object
  extended by org.apache.struts.chain.commands.ActionCommandBase
      extended by org.apache.struts.chain.commands.generic.CopyFormToContext
All Implemented Interfaces:
org.apache.commons.chain.Command, ActionCommand

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.

Version:
$Id: CopyFormToContext.java 471754 2006-11-06 14:55:09Z husted $

Field Summary
 
Fields inherited from interface org.apache.commons.chain.Command
CONTINUE_PROCESSING, PROCESSING_COMPLETE
 
Constructor Summary
CopyFormToContext()
           
 
Method Summary
 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, java.lang.String effectiveFormName, java.lang.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.
 java.lang.String getActionPath()
          Return ActionPath property.
 java.lang.String getFormName()
          Return FormName property.
 java.lang.String getScope()
          Return Scope property.
 java.lang.String getToKey()
          Return ToKey property.
 void setActionPath(java.lang.String actionPath)
          Set ActionPath property.
 void setFormName(java.lang.String formName)
          Set FormName property.
 void setScope(java.lang.String scope)
          Set Scope property.
 void setToKey(java.lang.String toKey)
          Set ToKey property.
 
Methods inherited from class org.apache.struts.chain.commands.ActionCommandBase
execute
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CopyFormToContext

public CopyFormToContext()
Method Detail

getActionPath

public java.lang.String getActionPath()

Return ActionPath property.

Returns:
ActionPath property

setActionPath

public void setActionPath(java.lang.String actionPath)

Set ActionPath property.

Parameters:
actionPath - New valuefor ActionPath

getFormName

public java.lang.String getFormName()

Return FormName property.

Returns:
FormName property

setFormName

public void setFormName(java.lang.String formName)

Set FormName property.

Parameters:
formName - New valuefor FormName

getScope

public java.lang.String getScope()

Return Scope property.

Returns:
Scope property

setScope

public void setScope(java.lang.String scope)

Set Scope property.

Parameters:
scope - New valuefor Scope

getToKey

public java.lang.String getToKey()

Return ToKey property.

Returns:
ToKey property

setToKey

public void setToKey(java.lang.String toKey)

Set ToKey property.

Parameters:
toKey - New valuefor FormName

execute

public boolean execute(ActionContext actionContext)
                throws java.lang.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.

Specified by:
execute in interface ActionCommand
Specified by:
execute in class ActionCommandBase
Parameters:
actionContext - Our ActionContext
Returns:
TRUE if processing should halt
Throws:
java.lang.Exception - on any error

findOrCreateForm

protected ActionForm findOrCreateForm(ActionContext context)
                               throws java.lang.IllegalAccessException,
                                      java.lang.InstantiationException

Based on the properties of this command and the given ActionContext, find or create an ActionForm instance for preparation.

Parameters:
context - ActionContextBase class that we are processing
Returns:
ActionForm instance
Throws:
java.lang.IllegalArgumentException - On ActionConfig not found
java.lang.IllegalStateException - On undefined scope and formbean
java.lang.IllegalAccessException - On failed instantiation
java.lang.InstantiationException - If ActionContext is not subsclass of ActionContextBase

findOrCreateForm

protected ActionForm findOrCreateForm(ActionContext ctx,
                                      java.lang.String effectiveFormName,
                                      java.lang.String effectiveScope)
                               throws java.lang.IllegalAccessException,
                                      java.lang.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.

Parameters:
ctx - The ActionContext we are processing
effectiveFormName - the target form name
effectiveScope - The target scope
Returns:
ActionForm instnace, storing in scope if created
Throws:
java.lang.InstantiationException - If ActionContext is not subsclass of ActionContextBase
java.lang.InstantiationException - If object cannot be created
java.lang.IllegalArgumentException - On form not found in/ scope
java.lang.IllegalAccessException - On failed instantiation
java.lang.IllegalStateException - If ActionContext is not a subclass of ActionBase


Copyright © 2000-2007 Apache Software Foundation. All Rights Reserved.