* @throws Exception
* on any error
*/
public boolean execute(ActionContext actionCtx) throws Exception {
// Is there a form bean associated with this ActionConfig?
ActionConfig actionConfig = actionCtx.getActionConfig();
String name = actionConfig.getName();
if (name == null) {
actionCtx.setActionForm(null);
return (false);
}
if (LOG.isTraceEnabled()) {
LOG.trace("Look up form-bean " + name);
}
// Look up the corresponding FormBeanConfig (if any)
FormBeanConfig formBeanConfig = actionConfig.getModuleConfig().findFormBeanConfig(name);
if (formBeanConfig == null) {
LOG.warn("No FormBeanConfig found in module " + actionConfig.getModuleConfig().getPrefix() + " under name "
+ name);
actionCtx.setActionForm(null);
return (false);
}
Map scope = actionCtx.getScope(actionConfig.getScope());
ActionForm instance;
instance = (ActionForm) scope.get(actionConfig.getAttribute());
// Can we recycle the existing instance (if any)?
if (!formBeanConfig.canReuse(instance)) {
instance = formBeanConfig.createActionForm(actionCtx);
}
// TODO: Remove ServletActionContext when ActionForm no longer
// directly depends on ActionServlet
if (actionCtx instanceof ServletActionContext) {
// The servlet property of ActionForm is transient, so
// ActionForms which are restored from a serialized state
// need to have their servlet restored.
ServletActionContext sac = (ServletActionContext) actionCtx;
instance.setServlet(sac.getActionServlet());
}
actionCtx.setActionForm(instance);
scope.put(actionConfig.getAttribute(), instance);
return (false);
}