resources.addFormSet(formSet);
resources.addFormSet(fs); resources.process();
private ValidatorResources setupDateResources(String property, String action) { ValidatorResources resources = new ValidatorResources(); ValidatorAction va = new ValidatorAction(); va.setName(action); va.setClassname("org.apache.commons.validator.ValidatorTest"); va.setMethod("formatDate"); va.setMethodParams("java.lang.Object,org.apache.commons.validator.Field"); FormSet fs = new FormSet(); Form form = new Form(); form.setName("testForm"); Field field = new Field(); field.setProperty(property); field.setDepends(action); form.addField(field); fs.addForm(form); resources.addValidatorAction(va); resources.addFormSet(fs); resources.process(); return resources; }
public void addFormSet(FormSet arg0) { resources.addFormSet(arg0); }
protected void setValidator(FormSet formSet) { ValidatorResources resource = StrutsUtil .getValidatorResources(getModuleConfigMetadata() .getModuleConfig()); resource.addFormSet(formSet); }
public Object invoke(MethodInvocation invocation) throws Throwable { String formKey; if (invocation.getArguments().length == 2) { formKey = (String) invocation.getArguments()[1]; } else { formKey = (String) invocation.getArguments()[3]; } if (formKey == null) { return invocation.proceed(); } ModuleConfig config = ModuleUtils.getInstance().getModuleConfig(S2StrutsContextUtil.getRequest()); Form form = this.validationCreator.createForm(config, formKey); if (form != null) { if (log.isDebugEnabled()) { log.debug("auto create " + form); } // initialize form... ValidatorResources resources = new ValidatorResources(); FormSet formSet = new FormSet(); formSet.addForm(form); resources.addFormSet(formSet); resources.process(); // ...initialized form return form; } return invocation.proceed(); }
resources.addFormSet(formSet);
resources.addFormSet(formSet);
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); } }