public class DynamicForm extends Form<DynamicForm.Dynamic>
HashMap<String,String>
Modifier and Type | Class and Description |
---|---|
static class |
DynamicForm.Dynamic
Simple data structure used by
DynamicForm . |
Form.Display, Form.Field
Constructor and Description |
---|
DynamicForm(java.util.Map<java.lang.String,java.lang.String> data,
java.util.List<ValidationError> errors,
java.util.Optional<DynamicForm.Dynamic> value,
MessagesApi messagesApi,
Formatters formatters,
javax.validation.ValidatorFactory validatorFactory,
com.typesafe.config.Config config)
Creates a new dynamic form.
|
DynamicForm(java.util.Map<java.lang.String,java.lang.String> data,
java.util.List<ValidationError> errors,
java.util.Optional<DynamicForm.Dynamic> value,
MessagesApi messagesApi,
Formatters formatters,
javax.validation.ValidatorFactory validatorFactory,
com.typesafe.config.Config config,
Lang lang)
Creates a new dynamic form.
|
DynamicForm(java.util.Map<java.lang.String,java.lang.String> data,
java.util.Map<java.lang.String,Http.MultipartFormData.FilePart<?>> files,
java.util.List<ValidationError> errors,
java.util.Optional<DynamicForm.Dynamic> value,
MessagesApi messagesApi,
Formatters formatters,
javax.validation.ValidatorFactory validatorFactory,
com.typesafe.config.Config config)
Creates a new dynamic form.
|
DynamicForm(java.util.Map<java.lang.String,java.lang.String> data,
java.util.Map<java.lang.String,Http.MultipartFormData.FilePart<?>> files,
java.util.List<ValidationError> errors,
java.util.Optional<DynamicForm.Dynamic> value,
MessagesApi messagesApi,
Formatters formatters,
javax.validation.ValidatorFactory validatorFactory,
com.typesafe.config.Config config,
Lang lang)
Creates a new dynamic form.
|
DynamicForm(MessagesApi messagesApi,
Formatters formatters,
javax.validation.ValidatorFactory validatorFactory,
com.typesafe.config.Config config)
Creates a new empty dynamic form.
|
Modifier and Type | Method and Description |
---|---|
DynamicForm |
bind(com.fasterxml.jackson.databind.JsonNode data,
java.lang.String... allowedFields)
Deprecated.
|
DynamicForm |
bind(Lang lang,
TypedMap attrs,
com.fasterxml.jackson.databind.JsonNode data,
java.lang.String... allowedFields)
Binds Json data to this form - that is, handles form submission.
|
DynamicForm |
bind(Lang lang,
TypedMap attrs,
java.util.Map<java.lang.String,java.lang.String> data,
java.util.Map<java.lang.String,Http.MultipartFormData.FilePart<?>> files,
java.lang.String... allowedFields)
Binds data to this form - that is, handles form submission.
|
DynamicForm |
bind(Lang lang,
TypedMap attrs,
java.util.Map<java.lang.String,java.lang.String> data,
java.lang.String... allowedFields)
Binds data to this form - that is, handles form submission.
|
DynamicForm |
bind(java.util.Map<java.lang.String,java.lang.String> data,
java.lang.String... allowedFields)
Deprecated.
|
DynamicForm |
bindFromRequest(Http.Request request,
java.lang.String... allowedFields)
Binds request data to this form - that is, handles form submission.
|
DynamicForm |
bindFromRequest(java.util.Map<java.lang.String,java.lang.String[]> requestData,
java.lang.String... allowedFields)
Deprecated.
|
DynamicForm |
bindFromRequest(java.lang.String... allowedFields)
Deprecated.
|
DynamicForm |
bindFromRequestData(Lang lang,
TypedMap attrs,
java.util.Map<java.lang.String,java.lang.String[]> requestData,
java.util.Map<java.lang.String,Http.MultipartFormData.FilePart<?>> requestFileData,
java.lang.String... allowedFields)
Binds request data to this form - that is, handles form submission.
|
DynamicForm |
discardingErrors() |
java.util.Optional<ValidationError> |
error(java.lang.String key) |
Form.Field |
field(java.lang.String key,
Lang lang)
Retrieves a field.
|
<A> Http.MultipartFormData.FilePart<A> |
file(java.lang.String key)
Gets the concrete value only if the submission was a success.
|
java.util.Map<java.lang.String,Http.MultipartFormData.FilePart<?>> |
files() |
DynamicForm |
fill(java.util.Map<java.lang.String,java.lang.Object> value)
Fills the form with existing data.
|
java.lang.String |
get(java.lang.String key)
Gets the concrete value only if the submission was a success.
|
java.util.Map<java.lang.String,java.lang.String> |
rawData() |
java.util.Optional<java.lang.Object> |
value(java.lang.String key)
Gets the concrete value
|
DynamicForm |
withDirectFieldAccess(boolean directFieldAccess)
Sets if during binding fields of the form should be accessed directly or via getters.
|
DynamicForm |
withError(java.lang.String key,
java.lang.String error) |
DynamicForm |
withError(java.lang.String key,
java.lang.String error,
java.util.List<java.lang.Object> args) |
DynamicForm |
withError(ValidationError error) |
DynamicForm |
withGlobalError(java.lang.String error) |
DynamicForm |
withGlobalError(java.lang.String error,
java.util.List<java.lang.Object> args) |
DynamicForm |
withLang(Lang lang)
A copy of this form with the given lang set which is used for formatting when retrieving a
field (via
Form.field(String) or Form.apply(String) ) and for translations in Form.errorsAsJson() . |
allErrors, apply, apply, bindFromRequestData, blankInstance, ctxLang, ctxRequestAttrs, errors, errors, errorsAsJson, errorsAsJson, field, fill, fillDataWith, get, get, getArgumentsForConstraint, getBackedType, getError, getGlobalError, getMessageForConstraintViolation, globalError, globalErrors, hasErrors, hasGlobalErrors, lang, name, requestData, requestFileData, resolveDuplicateFilePartKeys, toString, value
public DynamicForm(MessagesApi messagesApi, Formatters formatters, javax.validation.ValidatorFactory validatorFactory, com.typesafe.config.Config config)
messagesApi
- the messagesApi component.formatters
- the formatters component.validatorFactory
- the validatorFactory component.config
- the config component.public DynamicForm(java.util.Map<java.lang.String,java.lang.String> data, java.util.List<ValidationError> errors, java.util.Optional<DynamicForm.Dynamic> value, MessagesApi messagesApi, Formatters formatters, javax.validation.ValidatorFactory validatorFactory, com.typesafe.config.Config config)
data
- the current form data (used to display the form)errors
- the collection of errors associated with this formvalue
- optional concrete value if the form submission was successfulmessagesApi
- the messagesApi component.formatters
- the formatters component.validatorFactory
- the validatorFactory component.config
- the config component.public DynamicForm(java.util.Map<java.lang.String,java.lang.String> data, java.util.Map<java.lang.String,Http.MultipartFormData.FilePart<?>> files, java.util.List<ValidationError> errors, java.util.Optional<DynamicForm.Dynamic> value, MessagesApi messagesApi, Formatters formatters, javax.validation.ValidatorFactory validatorFactory, com.typesafe.config.Config config)
data
- the current form data (used to display the form)files
- the current form file dataerrors
- the collection of errors associated with this formvalue
- optional concrete value if the form submission was successfulmessagesApi
- the messagesApi component.formatters
- the formatters component.validatorFactory
- the validatorFactory component.config
- the config component.public DynamicForm(java.util.Map<java.lang.String,java.lang.String> data, java.util.List<ValidationError> errors, java.util.Optional<DynamicForm.Dynamic> value, MessagesApi messagesApi, Formatters formatters, javax.validation.ValidatorFactory validatorFactory, com.typesafe.config.Config config, Lang lang)
data
- the current form data (used to display the form)errors
- the collection of errors associated with this formvalue
- optional concrete value if the form submission was successfulmessagesApi
- the messagesApi component.formatters
- the formatters component.validatorFactory
- the validatorFactory component.config
- the config component.lang
- used for formatting when retrieving a field (via Form.field(String)
or Form.apply(String)
) and for translations in Form.errorsAsJson()
public DynamicForm(java.util.Map<java.lang.String,java.lang.String> data, java.util.Map<java.lang.String,Http.MultipartFormData.FilePart<?>> files, java.util.List<ValidationError> errors, java.util.Optional<DynamicForm.Dynamic> value, MessagesApi messagesApi, Formatters formatters, javax.validation.ValidatorFactory validatorFactory, com.typesafe.config.Config config, Lang lang)
data
- the current form data (used to display the form)files
- the current form file dataerrors
- the collection of errors associated with this formvalue
- optional concrete value if the form submission was successfulmessagesApi
- the messagesApi component.formatters
- the formatters component.validatorFactory
- the validatorFactory component.config
- the config component.lang
- used for formatting when retrieving a field (via Form.field(String)
or Form.apply(String)
) and for translations in Form.errorsAsJson()
public java.lang.String get(java.lang.String key)
value(String)
instead. If you
want to retrieve a file field use file(String)
instead.key
- the string key.public <A> Http.MultipartFormData.FilePart<A> file(java.lang.String key)
value(String)
instead. If
you want to retrieve a non-file field use get(String)
instead.key
- the string key.public java.util.Optional<java.lang.Object> value(java.lang.String key)
key
- the string key.public java.util.Map<java.lang.String,java.lang.String> rawData()
rawData
in class Form<DynamicForm.Dynamic>
Form.files()
to access files.public java.util.Map<java.lang.String,Http.MultipartFormData.FilePart<?>> files()
files
in class Form<DynamicForm.Dynamic>
Form.rawData()
to access other form data.public DynamicForm fill(java.util.Map<java.lang.String,java.lang.Object> value)
value
- the map of values to fill in the form.@Deprecated public DynamicForm bindFromRequest(java.lang.String... allowedFields)
Form
bindFromRequest
in class Form<DynamicForm.Dynamic>
allowedFields
- the fields that should be bound to the form, all fields if not specified.public DynamicForm bindFromRequest(Http.Request request, java.lang.String... allowedFields)
Form
bindFromRequest
in class Form<DynamicForm.Dynamic>
request
- the request to bind data from.allowedFields
- the fields that should be bound to the form, all fields if not specified.@Deprecated public DynamicForm bindFromRequest(java.util.Map<java.lang.String,java.lang.String[]> requestData, java.lang.String... allowedFields)
Form
bindFromRequest
in class Form<DynamicForm.Dynamic>
requestData
- the map of data to bind fromallowedFields
- the fields that should be bound to the form, all fields if not specified.public DynamicForm bindFromRequestData(Lang lang, TypedMap attrs, java.util.Map<java.lang.String,java.lang.String[]> requestData, java.util.Map<java.lang.String,Http.MultipartFormData.FilePart<?>> requestFileData, java.lang.String... allowedFields)
Form
bindFromRequestData
in class Form<DynamicForm.Dynamic>
lang
- used for validators and formatters during binding and is part of Constraints.ValidationPayload
. Later also used for formatting when retrieving a field (via Form.field(String)
or Form.apply(String)
) and for translations in Form.errorsAsJson()
.
For these methods the lang can be change via Form.withLang(Lang)
.attrs
- will be passed to validators via Constraints.ValidationPayload
requestData
- the map of data to bind fromrequestFileData
- the map of file data to bind fromallowedFields
- the fields that should be bound to the form, all fields if not specified.@Deprecated public DynamicForm bind(com.fasterxml.jackson.databind.JsonNode data, java.lang.String... allowedFields)
Form
bind
in class Form<DynamicForm.Dynamic>
data
- data to submitallowedFields
- the fields that should be bound to the form, all fields if not specified.public DynamicForm bind(Lang lang, TypedMap attrs, com.fasterxml.jackson.databind.JsonNode data, java.lang.String... allowedFields)
Form
bind
in class Form<DynamicForm.Dynamic>
lang
- used for validators and formatters during binding and is part of Constraints.ValidationPayload
. Later also used for formatting when retrieving a field (via Form.field(String)
or Form.apply(String)
) and for translations in Form.errorsAsJson()
.
For these methods the lang can be change via Form.withLang(Lang)
.attrs
- will be passed to validators via Constraints.ValidationPayload
data
- data to submitallowedFields
- the fields that should be bound to the form, all fields if not specified.@Deprecated public DynamicForm bind(java.util.Map<java.lang.String,java.lang.String> data, java.lang.String... allowedFields)
Form
bind
in class Form<DynamicForm.Dynamic>
data
- data to submitallowedFields
- the fields that should be bound to the form, all fields if not specified.public DynamicForm bind(Lang lang, TypedMap attrs, java.util.Map<java.lang.String,java.lang.String> data, java.lang.String... allowedFields)
Form
bind
in class Form<DynamicForm.Dynamic>
lang
- used for validators and formatters during binding and is part of Constraints.ValidationPayload
. Later also used for formatting when retrieving a field (via Form.field(String)
or Form.apply(String)
) and for translations in Form.errorsAsJson()
.
For these methods the lang can be change via Form.withLang(Lang)
.attrs
- will be passed to validators via Constraints.ValidationPayload
data
- data to submitallowedFields
- the fields that should be bound to the form, all fields if not specified.public DynamicForm bind(Lang lang, TypedMap attrs, java.util.Map<java.lang.String,java.lang.String> data, java.util.Map<java.lang.String,Http.MultipartFormData.FilePart<?>> files, java.lang.String... allowedFields)
Form
bind
in class Form<DynamicForm.Dynamic>
lang
- used for validators and formatters during binding and is part of Constraints.ValidationPayload
. Later also used for formatting when retrieving a field (via Form.field(String)
or Form.apply(String)
) and for translations in Form.errorsAsJson()
.
For these methods the lang can be change via Form.withLang(Lang)
.attrs
- will be passed to validators via Constraints.ValidationPayload
data
- data to submitallowedFields
- the fields that should be bound to the form, all fields if not specified.public Form.Field field(java.lang.String key, Lang lang)
Form
field
in class Form<DynamicForm.Dynamic>
key
- field namelang
- used for formattingpublic java.util.Optional<ValidationError> error(java.lang.String key)
error
in class Form<DynamicForm.Dynamic>
key
- the field name associated with the error.public DynamicForm withError(ValidationError error)
withError
in class Form<DynamicForm.Dynamic>
error
- the ValidationError
to add to the returned form.public DynamicForm withError(java.lang.String key, java.lang.String error, java.util.List<java.lang.Object> args)
withError
in class Form<DynamicForm.Dynamic>
key
- the error keyerror
- the error messageargs
- the error argumentspublic DynamicForm withError(java.lang.String key, java.lang.String error)
withError
in class Form<DynamicForm.Dynamic>
key
- the error keyerror
- the error messagepublic DynamicForm withGlobalError(java.lang.String error, java.util.List<java.lang.Object> args)
withGlobalError
in class Form<DynamicForm.Dynamic>
error
- the global error messageargs
- the global error argumentspublic DynamicForm withGlobalError(java.lang.String error)
withGlobalError
in class Form<DynamicForm.Dynamic>
error
- the global error messagepublic DynamicForm discardingErrors()
discardingErrors
in class Form<DynamicForm.Dynamic>
public DynamicForm withLang(Lang lang)
Form
Form.field(String)
or Form.apply(String)
) and for translations in Form.errorsAsJson()
.withLang
in class Form<DynamicForm.Dynamic>
public DynamicForm withDirectFieldAccess(boolean directFieldAccess)
Form
withDirectFieldAccess
in class Form<DynamicForm.Dynamic>
directFieldAccess
- true
enables direct field access during form binding, false
disables it and uses getters instead. If null
falls back to config default.