/** * Return the <code>Class</code> instance for the form bean implementation * configured by this <code>FormBeanConfig</code> instance. This method * uses the same algorithm as <code>RequestUtils.applicationClass()</code> * but is reproduced to avoid a runtime dependence. */ protected Class formBeanClass() { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); if (classLoader == null) { classLoader = this.getClass().getClassLoader(); } try { return (classLoader.loadClass(getType())); } catch (Exception e) { return (null); } }
/** * Return the <code>Class</code> instance for the form bean implementation * configured by this <code>FormBeanConfig</code> instance. This method * uses the same algorithm as <code>RequestUtils.applicationClass()</code> * but is reproduced to avoid a runtime dependence. */ protected Class formBeanClass() { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); if (classLoader == null) { classLoader = this.getClass().getClassLoader(); } try { return (classLoader.loadClass(getType())); } catch (Exception e) { return (null); } } }
private boolean canReusePojoForm(Object instance, FormBeanConfig config) { Class configClass = ClassUtil.forName(config.getType()); Object bean = BeanValidatorFormUtil.toBean(instance); return configClass.isAssignableFrom(bean.getClass()); }
private boolean isPojoForm(ActionMapping mapping, ModuleConfig moduleConfig) throws Throwable { FormBeanConfig formConfig = moduleConfig.findFormBeanConfig(mapping.getName()); if (formConfig == null) { return false; } Class fromClass = RequestUtils.applicationClass(formConfig.getType()); return !(ActionForm.class.isAssignableFrom(fromClass)); }
beanClass = RequestUtils.applicationClass(config.getType()); } catch (Throwable t) { throw new IllegalArgumentException ("Cannot instantiate ActionFormBean class '" + config.getType() + "': " + t); ("Class '" + config.getType() + "' is not a subclass of " + "'org.apache.struts.action.DynaActionForm'");
formType = "DynaActionForm"; } else { Class configClass = applicationClass(config.getType()); className = instance.getClass().getName(); canReuse = configClass.isAssignableFrom(instance.getClass());
beanClass = RequestUtils.applicationClass(config.getType()); } catch (Throwable t) { throw new IllegalArgumentException( "Cannot instantiate ActionFormBean class '" + config.getType() + "': " + t); throw new IllegalArgumentException("Class '" + config.getType() + "' is not a subclass of " + "'org.apache.struts.action.DynaActionForm'");
public Class getType() { synchronized (this) { if (moduleConfig == null) { WebContext wc = WebContextFactory.get(); moduleConfig = RequestUtils.getModuleConfig(wc.getHttpServletRequest(), wc.getServletContext()); // moduleConfig = ModuleUtils.getInstance().getModuleConfig("", wc.getServletContext()); //$NON-NLS-1$ // String moduleName = ModuleUtils.getInstance().getModuleName("/", wc.getServletContext()); // moduleConfig = ModuleUtils.getInstance().getModuleConfig(moduleName, wc.getServletContext()); } } try { return Class.forName(moduleConfig.findFormBeanConfig(formBean).getType()); } catch (ClassNotFoundException ex) { throw new IllegalArgumentException(Messages.getString("Creator.ClassNotFound", moduleConfig.findFormBeanConfig(formBean).getType())); //$NON-NLS-1$ } }
ClassUtils.getApplicationClass(this.getType());
beanType = formBeanConfig.getType();
log.error(servlet.getInternal().getMessage("formBean", config.getType()), e); return (null);
if (formBean.getType() == null) { handleValueRequiredException("type", formBean.getName(), "form bean");
beanType = formBeanConfig.getType();
private void registerValidations(ModuleConfig config) { // Create Forms. ValidatorResources currentResources = getValidatorResources(config); FormSet formSet = new FormSet(); FormBeanConfig[] formConfigs = config.findFormBeanConfigs(); for (int i = 0; i < formConfigs.length; i++) { if (!registeredValidation(currentResources, formConfigs[i])) { Class clazz = ClassUtil.forName(formConfigs[i].getType()); String name = formConfigs[i].getName(); Form form = this.validationCreator.createForm(config, clazz, name); if (form != null) { formSet.addForm(form); if (log.isDebugEnabled()) { log.debug("auto register " + form); } } } } // Initialize ValidatorResources if (formSet.getForms().size() != 0) { ValidatorResources resources = new ValidatorResources(); resources.addFormSet(formSet); resources.process(); addValidatorResources(config, resources); } }
if (formBean.getType() == null) { handleValueRequiredException("type", formBean.getName(), "form bean");