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;
}
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);
}
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;
}
}
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;
}
}
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;
}
Aggregations