Search in sources :

Example 1 with TextualFormField

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

the class TextualFormFieldBuilderImpl method build.

@Override
public TextualFormField build() {
    TextualFormField formField = new TextualFormFieldImpl();
    formField.setErrorI18nKey(getErrorI18nKey());
    formField.setI18nKey(getI18nKey());
    formField.setValue(getValue());
    if (StringUtils.isNotBlank(validationRegexp)) {
        formField.setValidationRegexp(validationRegexp);
    }
    return formField;
}
Also used : TextualFormField(org.asqatasun.webapp.form.TextualFormField) TextualFormFieldImpl(org.asqatasun.webapp.form.TextualFormFieldImpl)

Example 2 with TextualFormField

use of org.asqatasun.webapp.form.TextualFormField 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 3 with TextualFormField

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

the class ContractSortCommandFactory method getInitialisedContractDisplayCommand.

/**
     * 
     * @param userId
     * @param formFieldList
     * @return
     * An initialised auditCommand object for the given contract. This object
     * handles the last values selected by the user
     */
public ContractSortCommand getInitialisedContractDisplayCommand(Long userId, List<FormField> formFieldList) {
    ContractSortCommand contractDisplayCommand = new ContractSortCommand();
    for (FormField ff : formFieldList) {
        if (ff instanceof SelectFormField) {
            for (Map.Entry<String, List<SelectElement>> entry : ((SelectFormField) ff).getSelectElementMap().entrySet()) {
                for (SelectElement se : entry.getValue()) {
                    if (se.getDefaultElement() && se.getEnabled()) {
                        contractDisplayCommand.getSortOptionMap().put(entry.getKey(), se.getValue());
                    }
                }
            }
        } else if (ff instanceof TextualFormField) {
            contractDisplayCommand.getSortOptionMap().put(((TextualFormField) ff).getI18nKey(), ((TextualFormField) ff).getValue());
        }
    }
    contractDisplayCommand.setUserId(userId);
    return contractDisplayCommand;
}
Also used : SelectElement(org.asqatasun.webapp.form.SelectElement) TextualFormField(org.asqatasun.webapp.form.TextualFormField) List(java.util.List) SelectFormField(org.asqatasun.webapp.form.SelectFormField) FormField(org.asqatasun.webapp.form.FormField) TextualFormField(org.asqatasun.webapp.form.TextualFormField) Map(java.util.Map) ContractSortCommand(org.asqatasun.webapp.command.ContractSortCommand) SelectFormField(org.asqatasun.webapp.form.SelectFormField)

Aggregations

TextualFormField (org.asqatasun.webapp.form.TextualFormField)3 SelectFormField (org.asqatasun.webapp.form.SelectFormField)2 List (java.util.List)1 Map (java.util.Map)1 ContractSortCommand (org.asqatasun.webapp.command.ContractSortCommand)1 OptionElement (org.asqatasun.webapp.entity.option.OptionElement)1 FormField (org.asqatasun.webapp.form.FormField)1 NumericalFormField (org.asqatasun.webapp.form.NumericalFormField)1 SelectElement (org.asqatasun.webapp.form.SelectElement)1 TextualFormFieldImpl (org.asqatasun.webapp.form.TextualFormFieldImpl)1