Search in sources :

Example 6 with SelectFormField

use of org.asqatasun.webapp.ui.form.SelectFormField in project Asqatasun by Asqatasun.

the class AbstractAuditSetUpController method displayFormWithErrors.

/**
 * @param model
 * @param contract
 * @param auditSetUpCommand
 * @param authorisedReferentialList
 * @param parametersMap
 * @return
 */
private String displayFormWithErrors(Model model, Contract contract, AuditSetUpCommand auditSetUpCommand, Collection<String> authorisedReferentialList, Map<String, List<AuditSetUpFormField>> parametersMap) {
    model.addAttribute(TgolKeyStore.EXPANDED_KEY, TgolKeyStore.EXPANDED_VALUE);
    model.addAttribute(TgolKeyStore.AUDIT_SET_UP_COMMAND_KEY, auditSetUpCommand);
    model.addAttribute(TgolKeyStore.PARAMETERS_MAP_KEY, parametersMap);
    // Get a fresh list of the auditSetUpFormField that handles the choice
    // of the referential and its level
    List<SelectFormField> refAndLevelFormFieldList = this.getFreshRefAndLevelSetUpFormFieldList(authorisedReferentialList, referentialAndLevelFormFieldBuilderList);
    // Otherwise it corresponds to the default behaviour;
    // The selection of default level is delegated to the helper.
    // When the form is on error, the default level value corresponds to the
    // one the user has chosen.
    auditSetUpFormFieldHelper.selectDefaultLevelFromLevelValue(refAndLevelFormFieldList, auditSetUpCommand.getLevel());
    model.addAttribute(TgolKeyStore.LEVEL_LIST_KEY, refAndLevelFormFieldList);
    // if the user is authenticated, the url of the form is under
    // /home/contract/. To display error pages, we need to precise the
    // backward relative path and to add the breadCrumb.
    model.addAttribute(TgolKeyStore.CONTRACT_NAME_KEY, contract.getLabel());
    ScopeEnum auditScope = auditSetUpCommand.getScope();
    switch(auditScope) {
        case DOMAIN:
            return TgolKeyStore.AUDIT_SITE_SET_UP_VIEW_NAME;
        case PAGE:
            return TgolKeyStore.AUDIT_PAGE_SET_UP_VIEW_NAME;
        case FILE:
            return TgolKeyStore.AUDIT_UPLOAD_SET_UP_VIEW_NAME;
    }
    return TgolKeyStore.OUPS_VIEW_NAME;
}
Also used : ScopeEnum(org.asqatasun.entity.contract.ScopeEnum) SelectFormField(org.asqatasun.webapp.ui.form.SelectFormField)

Aggregations

SelectFormField (org.asqatasun.webapp.ui.form.SelectFormField)6 TextualFormField (org.asqatasun.webapp.ui.form.TextualFormField)2 List (java.util.List)1 Map (java.util.Map)1 Contract (org.asqatasun.entity.contract.Contract)1 ScopeEnum (org.asqatasun.entity.contract.ScopeEnum)1 OptionElementImpl (org.asqatasun.entity.option.OptionElementImpl)1 AuditSetUpCommand (org.asqatasun.webapp.command.AuditSetUpCommand)1 ContractSortCommand (org.asqatasun.webapp.command.ContractSortCommand)1 ForbiddenPageException (org.asqatasun.webapp.exception.ForbiddenPageException)1 FormField (org.asqatasun.webapp.ui.form.FormField)1 NumericalFormField (org.asqatasun.webapp.ui.form.NumericalFormField)1 SelectElement (org.asqatasun.webapp.ui.form.SelectElement)1