/** * Instantiates a new form that wraps the specified class. */ public static <T> Form<T> form(Class<T> clazz) { return new Form<T>(clazz); }
/** * Instantiates a new form that wraps the specified class. */ public static <T> Form<T> form(String name, Class<T> clazz, Class<?> group) { return new Form<T>(name, clazz, group); }
/** * @param clazz the class to map to a form. * @param <T> the type of value in the form. * @return a new form that wraps the specified class. */ public <T> Form<T> form(Class<T> clazz) { return new Form<>(clazz, messagesApi, formatters, validatorFactory, config); }
/** * @param <T> the type of value in the form. * @param name the form's name. * @param clazz the class to map to a form. * @return a new form that wraps the specified class. */ public <T> Form<T> form(String name, Class<T> clazz) { return new Form<>(name, clazz, messagesApi, formatters, validatorFactory, config); }
/** * @param <T> the type of value in the form. * @param name the form's name * @param clazz the class to map to a form. * @param groups the classes of groups. * @return a new form that wraps the specified class. */ public <T> Form<T> form(String name, Class<T> clazz, Class<?>... groups) { return new Form<>(name, clazz, groups, messagesApi, formatters, validatorFactory, config); }
/** * Sets if during binding fields of the form should be accessed directly or via getters. * * @param directFieldAccess {@code true} enables direct field access during form binding, {@code false} disables it and uses getters instead. If {@code null} falls back to config default. */ public Form<T> withDirectFieldAccess(boolean directFieldAccess) { return new Form<T>(this.rootName, this.backedType, this.rawData, this.files, this.errors, this.value, this.groups, this.messagesApi, this.formatters, this.validatorFactory, this.config, lang, directFieldAccess); }
/** * Sets if during binding fields of the form should be accessed directly or via getters. * * @param directFieldAccess {@code true} enables direct field access during form binding, {@code false} disables it and uses getters instead. If {@code null} falls back to config default. */ public Form<T> withDirectFieldAccess(boolean directFieldAccess) { return new Form<T>(this.rootName, this.backedType, this.rawData, this.files, this.errors, this.value, this.groups, this.messagesApi, this.formatters, this.validatorFactory, this.config, lang, directFieldAccess); }
/** * @param clazz the class to map to a form. * @param <T> the type of value in the form. * @return a new form that wraps the specified class. */ public <T> Form<T> form(Class<T> clazz) { return new Form<>(clazz, messagesApi, formatters, validatorFactory, config); }
/** * Instantiates a new form that wraps the specified class. */ public static <T> Form<T> form(String name, Class<T> clazz, Class<?> group) { return new Form<T>(name, clazz, group); }
/** * Instantiates a new form that wraps the specified class. */ public static <T> Form<T> form(Class<T> clazz, Class<?> group) { return new Form<T>(null, clazz, group); }
/** * Instantiates a new form that wraps the specified class. */ public static <T> Form<T> form(String name, Class<T> clazz) { return new Form<T>(name, clazz); }
/** * A copy of this form with the given lang set which is used for formatting when retrieving a field (via {@link #field(String)} or {@link #apply(String)}) * and for translations in {@link #errorsAsJson()}. */ public Form<T> withLang(Lang lang) { return new Form<T>(this.rootName, this.backedType, this.rawData, this.files, this.errors, this.value, this.groups, this.messagesApi, this.formatters, this.validatorFactory, this.config, lang, this.directFieldAccess); }
/** * @param <T> the type of value in the form. * @param name the form's name * @param clazz the class to map to a form. * @param groups the classes of groups. * @return a new form that wraps the specified class. */ public <T> Form<T> form(String name, Class<T> clazz, Class<?>... groups) { return new Form<>(name, clazz, groups, messagesApi, formatters, validatorFactory, config); }
/** * @param <T> the type of value in the form. * @param clazz the class to map to a form. * @param groups the classes of groups. * @return a new form that wraps the specified class. */ public <T> Form<T> form(Class<T> clazz, Class<?>... groups) { return new Form<>(null, clazz, groups, messagesApi, formatters, validatorFactory, config); }
/** * A copy of this form with the given lang set which is used for formatting when retrieving a field (via {@link #field(String)} or {@link #apply(String)}) * and for translations in {@link #errorsAsJson()}. */ public Form<T> withLang(Lang lang) { return new Form<T>(this.rootName, this.backedType, this.rawData, this.files, this.errors, this.value, this.groups, this.messagesApi, this.formatters, this.validatorFactory, this.config, lang, this.directFieldAccess); }
/** * @param clazz the class to map to a form. * @param <T> the type of value in the form. * @return a new form that wraps the specified class. */ public <T> Form<T> form(Class<T> clazz) { return new Form<>(clazz, messagesApi, formatters, validatorFactory, config); }
/** * @return a copy of this form but with the errors discarded. */ public Form<T> discardingErrors() { return new Form<T>(this.rootName, this.backedType, this.rawData, this.files, new ArrayList<>(), this.value, this.groups, this.messagesApi, this.formatters, this.validatorFactory, this.config, this.lang, this.directFieldAccess); }
/** * @return a copy of this form but with the errors discarded. */ public Form<T> discardingErrors() { return new Form<T>(this.rootName, this.backedType, this.rawData, this.files, new ArrayList<>(), this.value, this.groups, this.messagesApi, this.formatters, this.validatorFactory, this.config, this.lang, this.directFieldAccess); }
/** * @return a copy of this form but with the errors discarded. */ public Form<T> discardingErrors() { return new Form<T>(this.rootName, this.backedType, this.rawData, this.files, new ArrayList<>(), this.value, this.groups, this.messagesApi, this.formatters, this.validatorFactory, this.config, this.lang, this.directFieldAccess); }
@RequireCSRFCheck public static Result submitResetPassword() { Form<PasswordResetData> form = new Form<>(PasswordResetData.class).bindFromRequest(); if (!form.hasErrors() && isPasswordConfirmationCorrect(form) && tryResetPassword(form)) { return passwordResetService().passwordResetSuccessfulPage(form); } else { return passwordResetService().passwordResetPage(form); } }