/** * Retrieve a field. * * @param key field name * @return the field (even if the field does not exist you get a field) */ public Field apply(String key) { return field(key); }
/** * Retrieves a field. * * @param key field name * @param lang the language to use for the formatter * @return the field (even if the field does not exist you get a field) */ public Field apply(String key, Lang lang) { return field(key, lang); }
/** * Retrieves a field. * * @param key field name * @param lang the language to use for the formatter * @return the field (even if the field does not exist you get a field) */ public Field apply(String key, Lang lang) { return field(key, lang); }
/** * Retrieves a field. * * @param key field name * @return the field (even if the field does not exist you get a field) */ public Field field(final String key) { return field(key, this.lang); }
/** * Retrieves a field. * * @param key field name * @return the field (even if the field does not exist you get a field) */ public Field field(final String key) { return field(key, this.lang); }
/** * Retrieves a field. * * @param key field name * @param lang the language to use for the formatter * @return the field (even if the field does not exist you get a field) */ public Field apply(String key, Lang lang) { return field(key, lang); }
/** * Retrieve a field. * * @param key field name * @return the field (even if the field does not exist you get a field) */ public Field apply(String key) { return field(key); }
/** * Retrieves a field. * * @param key field name * @return the field (even if the field does not exist you get a field) */ public Field field(final String key) { return field(key, this.lang); }
/** * Get a sub-field, with a key relative to the current field. */ public Field sub(String key) { String subKey = null; if(key.startsWith("[")) { subKey = name + key; } else { subKey = name + "." + key; } return form.field(subKey); }
/** * Get a sub-field, with a key relative to the current field. */ public Field sub(String key) { String subKey = null; if(key.startsWith("[")) { subKey = name + key; } else { subKey = name + "." + key; } return form.field(subKey); }
@Nullable protected String getSelectedMethodId(final Form<?> form, final String fieldName) { return form.field(fieldName).value(); } }
@Nullable protected String getSelectedMethodId(final Form<?> form, final String fieldName) { return form.field(fieldName).value(); } }
@Nullable protected String getSelectedTitle(final Form<?> form, final String fieldName) { return form.field(fieldName).value(); }
@Nullable public static String extractFormField(@Nullable final Form<?> form, final String fieldName) { return form != null ? form.field(fieldName).value() : null; }
private Object resolveImpl(@Nonnull final Form<?> form, final String name) { if (name.equals("errors")) { return extractErrors(form); } else { final String value = form.field(name).value(); return isFalsy(value) ? false : firstNonNull(value, UNRESOLVED); } }
@Override public Form.Field field(String key, Lang lang) { // #1310: We specify inner class as Form.Field rather than Field because otherwise, // javadoc cannot find the static inner class. Field field = super.field(asDynamicKey(key), lang); return new Field(this, key, field.constraints(), field.format(), field.errors(), field.value().orElse(value(key).map(v -> v instanceof String ? (String)v : null).orElse(null)), field.file().orElse(value(key).map(v -> v instanceof Http.MultipartFormData.FilePart ? (Http.MultipartFormData.FilePart)v : null).orElse(null)) ); }
@Override public Form.Field field(String key, Lang lang) { // #1310: We specify inner class as Form.Field rather than Field because otherwise, // javadoc cannot find the static inner class. Field field = super.field(asDynamicKey(key), lang); return new Field(this, key, field.constraints(), field.format(), field.errors(), field.value().orElse(value(key).map(v -> v instanceof String ? (String)v : null).orElse(null)), field.file().orElse(value(key).map(v -> v instanceof Http.MultipartFormData.FilePart ? (Http.MultipartFormData.FilePart)v : null).orElse(null)) ); }
@Override public Form.Field field(String key, Lang lang) { // #1310: We specify inner class as Form.Field rather than Field because otherwise, // javadoc cannot find the static inner class. Field field = super.field(asDynamicKey(key), lang); return new Field(this, key, field.constraints(), field.format(), field.errors(), field.value().orElse(value(key).map(v -> v instanceof String ? (String)v : null).orElse(null)), field.file().orElse(value(key).map(v -> v instanceof Http.MultipartFormData.FilePart ? (Http.MultipartFormData.FilePart)v : null).orElse(null)) ); }
public boolean tryLogIn(Form<?> loginForm) { String email = loginForm.field(EMAIL_FIELD).value(); String password = loginForm.field(PASSWORD_FIELD).value(); PlessUser authenticatedUser = passwordAuthenticator().tryAuthenticateUser(email, password); if (authenticatedUser != null) { authenticationService().logIn(authenticatedUser); return true; } loginForm.reject(EMAIL_FIELD, "Login failed due to an incorrect email or password."); return false; }
/** * Retrieves a field. * * @param key field name * @return the field - even if the field does not exist you get a field */ public Field field(String key) { Field field = super.field(asDynamicKey(key)); return new Field(this, key, field.constraints(), field.format(), field.errors(), field.value() == null ? get(key) : field.value() ); }