Example usage for org.apache.commons.validator FormSet FormSet

List of usage examples for org.apache.commons.validator FormSet FormSet

Introduction

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

Prototype

FormSet

Source Link

Usage

From source file:org.agnitas.service.impl.NewImportWizardServiceImpl.java

public void handleRow(String[] row) throws Exception {
    // If we haven't been sent the header data yet then we store them (but don't process them)
    if (columns == null) {
        columns = filedsFactory.createColumnHeader(row, importProfile);
        // final Form form = resources.getForm(Locale.getDefault(), FORM_NAME);
        final Form customForm = new Form();
        customForm.setName(FORM_NAME);//from   ww w  .  j a va2 s  . c o m
        final FormSet formSet = new FormSet();
        formSet.addForm(customForm);
        resources.addFormSet(formSet);
        filedsFactory.createRulesForCustomFields(columns, customForm, importRecipientsDao, importProfile);
        initColumnsNullableCheck(columns);
    } else {
        push("fields");
        setDefaultMailType();
        for (int idx = 0; (idx < columns.length) && (idx < row.length); idx++) {
            /*
             * if(!columns[idx].getImportedColumn()) { continue; }
             */
            String value = row[idx];
            if (StringUtils.isEmpty(value)) {
                value = getDefaultValueFromImportProfile(idx);
            }

            if (columns[idx].getColName().toLowerCase().equals(ImportUtils.MAIL_TYPE_DB_COLUMN)) {
                value = adjustMailtype(value);
                if (value != null) {
                    push("mailtypeDefined");
                    apply(ImportUtils.MAIL_TYPE_DEFINED);
                    pop("mailtypeDefined");
                }
            }

            push(columns[idx].getColName());
            apply(value);
            pop(columns[idx].getColName());
        }
        pop("fields");
    }
}

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 w  w.  ja  va  2  s .  c o 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;/*from  w w  w .  j  a  v a 2s.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();
}