/** * Returns all errors. * * @return All errors associated with this form. * * @deprecated Deprecated as of 2.7.0. Method has been renamed to {@link #errors()}. */ @Deprecated public List<ValidationError> allErrors() { return errors(); }
/** * Returns all errors. * * @return All errors associated with this form. * * @deprecated Deprecated as of 2.7.0. Method has been renamed to {@link #errors()}. */ @Deprecated public List<ValidationError> allErrors() { return errors(); }
/** * Returns all errors. * * @return All errors associated with this form. * * @deprecated Deprecated as of 2.7.0. Method has been renamed to {@link #errors()}. */ @Deprecated public List<ValidationError> allErrors() { return errors(); }
/** * @param key the field name associated with the error. * @return an error by key */ public Optional<ValidationError> error(String key) { return errors(key).stream().findFirst(); }
@Deprecated public ErrorsBean(final List<Form<?>> filledForms) { this.globalErrors = new ArrayList<>(); filledForms.forEach(filledForm -> filledForm.errors().forEach((field, errors) -> errors.forEach(error -> globalErrors.add(new ErrorBean(field, error.key() + ": " + error.message()))))); }
@Override public DynamicForm bind(Lang lang, TypedMap attrs, Map<String,String> data, Map<String, Http.MultipartFormData.FilePart<?>> files, String... allowedFields) { Form<Dynamic> form = super.bind(lang, attrs, data.entrySet().stream().collect(Collectors.toMap(e -> asDynamicKey(e.getKey()), e -> e.getValue())), files.entrySet().stream().collect(Collectors.toMap(e -> asDynamicKey(e.getKey()), e -> e.getValue())), allowedFields); return new DynamicForm(form.rawData(), form.files(), form.errors(), form.value(), messagesApi, formatters, validatorFactory, config, lang); }
@Override public DynamicForm bind(Lang lang, TypedMap attrs, Map<String,String> data, Map<String, Http.MultipartFormData.FilePart<?>> files, String... allowedFields) { Form<Dynamic> form = super.bind(lang, attrs, data.entrySet().stream().collect(Collectors.toMap(e -> asDynamicKey(e.getKey()), e -> e.getValue())), files.entrySet().stream().collect(Collectors.toMap(e -> asDynamicKey(e.getKey()), e -> e.getValue())), allowedFields); return new DynamicForm(form.rawData(), form.files(), form.errors(), form.value(), messagesApi, formatters, validatorFactory, config, lang); }
ErrorsBean extractErrors(@Nullable final Form<?> form) { final ErrorsBean errorsBean = new ErrorsBean(); final List<ErrorBean> errorList = new ArrayList<>(); if (form != null) { form.errors().forEach((field, errors) -> errors.forEach(error -> { final String errorMessage = errorFormatter.format(locales, error); errorList.add(new ErrorBean(field, errorMessage)); })); } errorsBean.setGlobalErrors(errorList); return errorsBean; } }
@Override public DynamicForm discardingErrors() { final Form<Dynamic> form = super.discardingErrors(); return new DynamicForm(super.rawData(), super.files(), form.errors(), form.value(), this.messagesApi, this.formatters, this.validatorFactory, this.config, lang().orElse(null)); }
@Override public DynamicForm withGlobalError(final String error, final List<Object> args) { final Form<Dynamic> form = super.withGlobalError(error, args); return new DynamicForm(super.rawData(), super.files(), form.errors(), form.value(), this.messagesApi, this.formatters, this.validatorFactory, this.config, lang().orElse(null)); }
@Override public DynamicForm discardingErrors() { final Form<Dynamic> form = super.discardingErrors(); return new DynamicForm(super.rawData(), super.files(), form.errors(), form.value(), this.messagesApi, this.formatters, this.validatorFactory, this.config, lang().orElse(null)); }
@Override public DynamicForm withGlobalError(final String error, final List<Object> args) { final Form<Dynamic> form = super.withGlobalError(error, args); return new DynamicForm(super.rawData(), super.files(), form.errors(), form.value(), this.messagesApi, this.formatters, this.validatorFactory, this.config, lang().orElse(null)); }
@Override public DynamicForm discardingErrors() { final Form<Dynamic> form = super.discardingErrors(); return new DynamicForm(super.rawData(), super.files(), form.errors(), form.value(), this.messagesApi, this.formatters, this.validatorFactory, this.config, lang().orElse(null)); }
/** * Fille with existing data. */ public DynamicForm fill(Map value) { Form<Dynamic> form = super.fill(new Dynamic(value)); return new DynamicForm(form.data(), form.errors(), form.value()); }
/** * Fills the form with existing data. * @param value the map of values to fill in the form. * @return the modified form. */ public DynamicForm fill(Map<String, Object> value) { Form<Dynamic> form = super.fill(new Dynamic(value)); return new DynamicForm(form.rawData(), form.files(), form.errors(), form.value(), messagesApi, formatters, validatorFactory, config, lang().orElse(null)); }
@Override public DynamicForm withError(final String key, final String error, final List<Object> args) { final Form<Dynamic> form = super.withError(asDynamicKey(key), error, args); return new DynamicForm(super.rawData(), super.files(), form.errors(), form.value(), this.messagesApi, this.formatters, this.validatorFactory, this.config, lang().orElse(null)); }
@Override public DynamicForm withError(final String key, final String error, final List<Object> args) { final Form<Dynamic> form = super.withError(asDynamicKey(key), error, args); return new DynamicForm(super.rawData(), super.files(), form.errors(), form.value(), this.messagesApi, this.formatters, this.validatorFactory, this.config, lang().orElse(null)); }
/** * Fills the form with existing data. * @param value the map of values to fill in the form. * @return the modified form. */ public DynamicForm fill(Map<String, Object> value) { Form<Dynamic> form = super.fill(new Dynamic(value)); return new DynamicForm(form.rawData(), form.files(), form.errors(), form.value(), messagesApi, formatters, validatorFactory, config, lang().orElse(null)); }
@Override public DynamicForm withError(final ValidationError error) { final Form<Dynamic> form = super.withError(new ValidationError(asDynamicKey(error.key()), error.messages(), error.arguments())); return new DynamicForm(super.rawData(), super.files(), form.errors(), form.value(), this.messagesApi, this.formatters, this.validatorFactory, this.config, lang().orElse(null)); }
@Override public DynamicForm withError(final ValidationError error) { final Form<Dynamic> form = super.withError(new ValidationError(asDynamicKey(error.key()), error.messages(), error.arguments())); return new DynamicForm(super.rawData(), super.files(), form.errors(), form.value(), this.messagesApi, this.formatters, this.validatorFactory, this.config, lang().orElse(null)); }