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(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(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 |
bindFromRequest(Http.Request request,
java.lang.String... allowedFields)
Binds request data to this form - that is, handles form submission.
|
DynamicForm |
bindFromRequest(java.lang.String... allowedFields)
Binds request data to this form - that is, handles form submission.
|
java.util.Optional<ValidationError> |
error(java.lang.String key)
Retrieve an error by key.
|
Form.Field |
field(java.lang.String key)
Retrieves a field.
|
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.Optional<ValidationError> |
getError(java.lang.String key)
Deprecated.
Deprecated as of 2.7.0. Method has been renamed to
error(String) . |
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 |
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) |
allErrors, apply, bind, bindFromRequest, blankInstance, discardingErrors, errors, errors, errorsAsJson, errorsAsJson, fill, get, getArgumentsForConstraint, getBackedType, getGlobalError, getMessageForConstraintViolation, globalError, globalErrors, hasErrors, hasGlobalErrors, name, requestData, toString, value, withError, withGlobalError, withGlobalError
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 java.lang.String get(java.lang.String key)
value(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>
public DynamicForm fill(java.util.Map<java.lang.String,java.lang.Object> value)
value
- the map of values to fill in the form.public DynamicForm bindFromRequest(java.lang.String... allowedFields)
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)
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.public DynamicForm bind(java.util.Map<java.lang.String,java.lang.String> data, java.lang.String... allowedFields)
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 Form.Field field(java.lang.String key)
field
in class Form<DynamicForm.Dynamic>
key
- field name@Deprecated public java.util.Optional<ValidationError> getError(java.lang.String key)
error(String)
.getError
in class Form<DynamicForm.Dynamic>
key
- the field name associated with the error.public 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(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 message