Example usage for org.apache.commons.validator Form setName

List of usage examples for org.apache.commons.validator Form setName

Introduction

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

Prototype

public void setName(String name) 

Source Link

Document

Sets the name/key of the set of validation rules.

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);
        final FormSet formSet = new FormSet();
        formSet.addForm(customForm);// www  .j  a v  a  2 s . co  m
        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.customizer.ActionCustomizer.java

/**
 * ????//from  w w w. j  a  v a  2s .c om
 * 
 * 
 * @param actionMapping
 *            
 * @param validatorResources
 *            
 */
protected void setupValidator(S2ActionMapping actionMapping, S2ValidatorResources validatorResources) {
    Map<String, Form> forms = new HashMap<String, Form>();
    for (String methodName : actionMapping.getExecuteMethodNames()) {
        if (actionMapping.getExecuteConfig(methodName).isValidator()) {
            Form form = new Form();
            form.setName(actionMapping.getName() + "_" + methodName);
            forms.put(methodName, form);
        }
    }
    for (Class<?> clazz = actionMapping.getActionFormBeanDesc().getBeanClass(); clazz != null
            && clazz != Object.class; clazz = clazz.getSuperclass()) {
        for (Field field : ClassUtil.getDeclaredFields(clazz)) {
            for (Annotation anno : field.getDeclaredAnnotations()) {
                processAnnotation(field.getName(), anno, validatorResources, forms);
            }
        }
    }
    for (Iterator<Form> i = forms.values().iterator(); i.hasNext();) {
        validatorResources.addForm(i.next());
    }

}

From source file:org.seasar.struts.lessconfig.factory.AbstractValidatorAnnotationHandler.java

public Form createForm(String formName, Class formClass) {
    Form form = new Form();
    form.setName(formName);

    BeanDesc beanDesc = BeanDescFactory.getBeanDesc(formClass);
    registerFields(form, new Field(), beanDesc);
    return form;/*w ww.j av  a 2 s.c om*/
}