Search in sources :

Example 1 with ValidationStatus

use of org.olat.core.util.ValidationStatus in project OpenOLAT by OpenOLAT.

the class Form method submit.

private final void submit(UserRequest ureq, Event validationOkEvent) {
    ValidatingFormComponentVisitor vfcv = new ValidatingFormComponentVisitor();
    FormComponentTraverser ct = new FormComponentTraverser(vfcv, formLayout, false);
    ct.visitAll(ureq);
    // validate all form elements and gather validation status
    ValidationStatus[] status = vfcv.getStatus();
    // 
    boolean isValid = status == null || status.length == 0;
    for (Iterator<FormBasicController> iterator = formListeners.iterator(); iterator.hasNext(); ) {
        FormBasicController fbc = iterator.next();
        // let all listeners validate and calc the total isValid
        // let further validate even if one fails.
        isValid = fbc.validateFormLogic(ureq) && isValid;
    }
    formWrapperComponent.fireValidation(ureq, isValid, validationOkEvent);
    isValidAndSubmitted = isValid;
    hasAlreadyFired = true;
}
Also used : ValidationStatus(org.olat.core.util.ValidationStatus) FormComponentTraverser(org.olat.core.util.component.FormComponentTraverser)

Example 2 with ValidationStatus

use of org.olat.core.util.ValidationStatus in project OpenOLAT by OpenOLAT.

the class AddOpenIDConnectIFFullConfigurableController method validateFormLogic.

@Override
protected boolean validateFormLogic(UserRequest ureq) {
    boolean allOk = true;
    allOk &= validate(openIdConnectIFName);
    List<ValidationStatus> nameValidation = new ArrayList<ValidationStatus>();
    openIdConnectIFName.validate(nameValidation);
    allOk &= nameValidation.isEmpty();
    allOk &= validate(openIdConnectIFDisplayName);
    allOk &= validate(openIdConnectIFApiKeyEl);
    allOk &= validate(openIdConnectIFApiSecretEl);
    allOk &= validate(openIdConnectIFIssuerEl);
    allOk &= validate(openIdConnectIFAuthorizationEndPointEl);
    String providerName = openIdConnectIFName.getValue();
    if (StringHelper.containsNonWhitespace(providerName)) {
        OAuthSPI existingSpi = oauthModule.getProvider(providerName);
        if (existingSpi != null) {
            openIdConnectIFName.setErrorKey("error.duplicate.provider", null);
            allOk &= false;
        }
    }
    return allOk & super.validateFormLogic(ureq);
}
Also used : ValidationStatus(org.olat.core.util.ValidationStatus) ArrayList(java.util.ArrayList) OAuthSPI(org.olat.login.oauth.OAuthSPI)

Example 3 with ValidationStatus

use of org.olat.core.util.ValidationStatus in project OpenOLAT by OpenOLAT.

the class DatePropertyHandler method isValid.

/**
 * @see org.olat.user.propertyhandlers.UserPropertyHandler#isValid(org.olat.core.gui.components.form.flexible.FormItem, java.util.Map)
 */
@Override
public boolean isValid(User user, FormItem formItem, Map<String, String> formContext) {
    DateChooser dateElem = (DateChooser) formItem;
    if (dateElem.isEmpty()) {
        return !dateElem.isMandatory() || !dateElem.isEmpty("new.form.mandatory");
    }
    List<ValidationStatus> validation = new ArrayList<ValidationStatus>();
    dateElem.validate(validation);
    if (validation.size() == 0) {
        return true;
    } else {
        // errorkey should be set by dateElem.validate formItem.setErrorKey(i18nFormElementLabelKey()+ ".error", null);
        return false;
    }
}
Also used : ValidationStatus(org.olat.core.util.ValidationStatus) ArrayList(java.util.ArrayList) DateChooser(org.olat.core.gui.components.form.flexible.elements.DateChooser)

Example 4 with ValidationStatus

use of org.olat.core.util.ValidationStatus in project openolat by klemens.

the class DatePropertyHandler method isValid.

/**
 * @see org.olat.user.propertyhandlers.UserPropertyHandler#isValid(org.olat.core.gui.components.form.flexible.FormItem, java.util.Map)
 */
@Override
public boolean isValid(User user, FormItem formItem, Map<String, String> formContext) {
    DateChooser dateElem = (DateChooser) formItem;
    if (dateElem.isEmpty()) {
        return !dateElem.isMandatory() || !dateElem.isEmpty("new.form.mandatory");
    }
    List<ValidationStatus> validation = new ArrayList<ValidationStatus>();
    dateElem.validate(validation);
    if (validation.size() == 0) {
        return true;
    } else {
        // errorkey should be set by dateElem.validate formItem.setErrorKey(i18nFormElementLabelKey()+ ".error", null);
        return false;
    }
}
Also used : ValidationStatus(org.olat.core.util.ValidationStatus) ArrayList(java.util.ArrayList) DateChooser(org.olat.core.gui.components.form.flexible.elements.DateChooser)

Example 5 with ValidationStatus

use of org.olat.core.util.ValidationStatus in project openolat by klemens.

the class Form method submit.

private final void submit(UserRequest ureq, Event validationOkEvent) {
    ValidatingFormComponentVisitor vfcv = new ValidatingFormComponentVisitor();
    FormComponentTraverser ct = new FormComponentTraverser(vfcv, formLayout, false);
    ct.visitAll(ureq);
    // validate all form elements and gather validation status
    ValidationStatus[] status = vfcv.getStatus();
    // 
    boolean isValid = status == null || status.length == 0;
    for (Iterator<FormBasicController> iterator = formListeners.iterator(); iterator.hasNext(); ) {
        FormBasicController fbc = iterator.next();
        // let all listeners validate and calc the total isValid
        // let further validate even if one fails.
        isValid = fbc.validateFormLogic(ureq) && isValid;
    }
    formWrapperComponent.fireValidation(ureq, isValid, validationOkEvent);
    isValidAndSubmitted = isValid;
    hasAlreadyFired = true;
}
Also used : ValidationStatus(org.olat.core.util.ValidationStatus) FormComponentTraverser(org.olat.core.util.component.FormComponentTraverser)

Aggregations

ValidationStatus (org.olat.core.util.ValidationStatus)6 ArrayList (java.util.ArrayList)4 DateChooser (org.olat.core.gui.components.form.flexible.elements.DateChooser)2 FormComponentTraverser (org.olat.core.util.component.FormComponentTraverser)2 OAuthSPI (org.olat.login.oauth.OAuthSPI)2