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

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

Introduction

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

Prototype

public void process() 

Source Link

Document

Process the 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);//w  ww . j  a  va  2s .  co  m

                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;/*  www .ja  v a2  s  . c om*/
    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();
}