public static ActionForm createActionForm( ActionMapping mapping, ModuleConfig moduleConfig,
ActionServlet actionServlet, ServletContext servletContext )
{
String formName = mapping.getName();
if ( formName == null ) return null;
FormBeanConfig config = moduleConfig.findFormBeanConfig( formName );
if ( config == null ) return null;
try
{
ActionForm bean;
if ( config.getDynamic() )
{
if ( _log.isDebugEnabled() )
{
_log.debug( "Creating new DynaActionForm instance of type " + config.getType() );
}
DynaActionFormClass dynaClass = DynaActionFormClass.createDynaActionFormClass( config );
bean = ( ActionForm ) dynaClass.newInstance();
( ( DynaActionForm ) bean ).initialize( mapping );
}
else
{
if ( _log.isDebugEnabled() )
{
_log.debug( "Creating new ActionForm instance of type " + config.getType() );
}
bean = ( ActionForm ) newReloadableInstance( config.getType(), servletContext );
}
bean.setServlet( actionServlet );
return bean;
}
catch ( Exception e )
{
if ( _log.isErrorEnabled() )
{
_log.error( "Error creating action form of type " + config.getType(), e );
}
return null;
}
}