return (null);
}
// Look up the form bean configuration information to use
String name = mapping.getName();
FormBeanConfig config = appConfig.findFormBeanConfig(name);
if (config == null) {
return (null);
}
// Look up any existing form bean instance
if (appConfig.getControllerConfig().getDebug() >= 2) {
LOG.info(" Looking for ActionForm bean instance in scope '" +
mapping.getScope() + "' under attribute key '" +
attribute + "'");
}
ActionForm instance = null;
HttpSession session = null;
if ("request".equals(mapping.getScope())) {
instance = (ActionForm) request.getAttribute(attribute);
} else {
session = request.getSession();
instance = (ActionForm) session.getAttribute(attribute);
}
// Can we recycle the existing form bean instance (if there is one)?
if (instance != null) {
if (config.getDynamic()) {
String className =
((DynaBean) instance).getDynaClass().getName();
if (className.equals(config.getName())) {
if (appConfig.getControllerConfig().getDebug() >= 2) {
servlet.log
(" Recycling existing DynaActionForm instance " +
"of type '" + className + "'");
}
return (instance);
}
} else {
String className =
instance.getClass().getName();
if (className.equals(config.getType())) {
if (appConfig.getControllerConfig().getDebug() >= 2) {
servlet.log
(" Recycling existing ActionForm instance " +
"of class '" + className + "'");
}
return (instance);
}
}
}
// Create and return a new form bean instance
if (config.getDynamic()) {
try {
DynaActionFormClass dynaClass =
DynaActionFormClass.createDynaActionFormClass(config);
instance = (ActionForm) dynaClass.newInstance();
} catch (Throwable t) {
LOG.error(servlet.getInternal().getMessage
("formBean", config.getName()), t);
return (null);
}
} else {
try {
instance = (ActionForm) applicationInstance(config.getType());
} catch (Throwable t) {
LOG.error(servlet.getInternal().getMessage
("formBean", config.getType()), t);
return (null);
}
}
instance.setServlet(servlet);
instance.reset(mapping, request);