Example usage for org.apache.commons.validator ValidatorResources addFormSet

List of usage examples for org.apache.commons.validator ValidatorResources addFormSet

Introduction

In this page you can find the example usage for org.apache.commons.validator ValidatorResources addFormSet.

Prototype

public void addFormSet(FormSet fs) 

Source Link

Document

Add a FormSet to this ValidatorResources object.

Usage

From source file:org.seasar.struts.lessconfig.autoregister.impl.StrutsConfigRegisterImpl.java

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);/*from  ww w.  j  a  v  a 2 s .com*/

                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);
    }
}

From source file:org.seasar.struts.lessconfig.hotdeploy.OndemandGetFormInterceptor.java

public Object invoke(MethodInvocation invocation) throws Throwable {
    String formKey;//from w  ww  . j  a  va  2 s.com
    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();
}