Search in sources :

Example 1 with NumericalFormField

use of org.asqatasun.webapp.form.NumericalFormField in project Asqatasun by Asqatasun.

the class AuditSetUpFormFieldHelper method applyRestrictionToAuditSetUpFormField.

/**
     * A restriction can be applied to an AuditSetUpFormField when an option
     * matches with a parameter (by its code). In this case, regarding the type
     * of the FormField, the value of the option override the default
     *
     * @param ap
     * @param optionElementSet
     */
public static void applyRestrictionToAuditSetUpFormField(AuditSetUpFormField ap, Collection<OptionElement> optionElementSet) {
    if (ap.getFormField() instanceof NumericalFormField) {
        OptionElement optionElement = getOptionFromOptionSet(optionElementSet, ap.getParameterElement().getParameterElementCode());
        if (optionElement != null) {
            ((NumericalFormField) ap.getFormField()).setMaxValue(optionElement.getValue());
            ((NumericalFormField) ap.getFormField()).setValue(optionElement.getValue());
        }
    } else if (ap.getFormField() instanceof SelectFormField) {
        activateSelectFormField((SelectFormField) ap.getFormField(), optionElementSet);
    } else if (ap.getFormField() instanceof TextualFormField) {
        OptionElement optionElement = getOptionFromOptionSet(optionElementSet, ap.getParameterElement().getParameterElementCode());
        if (optionElement != null) {
            ((TextualFormField) ap.getFormField()).setValue(optionElement.getValue());
        }
    }
}
Also used : TextualFormField(org.asqatasun.webapp.form.TextualFormField) OptionElement(org.asqatasun.webapp.entity.option.OptionElement) NumericalFormField(org.asqatasun.webapp.form.NumericalFormField) SelectFormField(org.asqatasun.webapp.form.SelectFormField)

Example 2 with NumericalFormField

use of org.asqatasun.webapp.form.NumericalFormField in project Asqatasun by Asqatasun.

the class NumericalFormFieldBuilderImpl method build.

@Override
public NumericalFormField build() {
    NumericalFormField formField = new NumericalFormFieldImpl();
    formField.setErrorI18nKey(getErrorI18nKey());
    formField.setI18nKey(getI18nKey());
    formField.setValue(getValue());
    formField.setMaxValue(maxValue);
    formField.setMinValue(minValue);
    return formField;
}
Also used : NumericalFormField(org.asqatasun.webapp.form.NumericalFormField) NumericalFormFieldImpl(org.asqatasun.webapp.form.NumericalFormFieldImpl)

Aggregations

NumericalFormField (org.asqatasun.webapp.form.NumericalFormField)2 OptionElement (org.asqatasun.webapp.entity.option.OptionElement)1 NumericalFormFieldImpl (org.asqatasun.webapp.form.NumericalFormFieldImpl)1 SelectFormField (org.asqatasun.webapp.form.SelectFormField)1 TextualFormField (org.asqatasun.webapp.form.TextualFormField)1