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.Validator validator)
Creates a new dynamic form.
|
DynamicForm(java.util.Map<java.lang.String,java.lang.String> data,
java.util.Map<java.lang.String,java.util.List<ValidationError>> errors,
java.util.Optional<DynamicForm.Dynamic> value,
MessagesApi messagesApi,
Formatters formatters,
javax.validation.Validator validator)
Deprecated.
Deprecated as of 2.6.0. Replace the parameter
Map<String,List<ValidationError>> with a simple List<ValidationError> . |
DynamicForm(MessagesApi messagesApi,
Formatters formatters,
javax.validation.Validator validator)
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.Map<java.lang.String,java.lang.String> |
data()
Deprecated.
|
ValidationError |
error(java.lang.String key)
Deprecated.
Deprecated as of 2.6.0. Use
getError(String) instead. |
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)
Retrieve an error by key.
|
java.util.Map<java.lang.String,java.lang.String> |
rawData() |
void |
reject(java.lang.String key,
java.lang.String error)
Deprecated.
Deprecated as of 2.6.0. Use
withError(String, String) instead. |
void |
reject(java.lang.String key,
java.lang.String error,
java.util.List<java.lang.Object> args)
Deprecated.
Deprecated as of 2.6.0. Use
withError(String, String, List) instead. |
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, discardErrors, discardingErrors, errors, errors, errorsAsJson, errorsAsJson, fill, get, getArgumentsForConstraint, getBackedType, getGlobalError, getMessageForConstraintViolation, globalError, globalErrors, hasErrors, hasGlobalErrors, name, reject, reject, reject, requestData, toString, value, withError, withGlobalError, withGlobalError
public DynamicForm(MessagesApi messagesApi, Formatters formatters, javax.validation.Validator validator)
messagesApi
- the messagesApi component.formatters
- the formatters component.validator
- the validator 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.Validator validator)
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.validator
- the validator component.@Deprecated public DynamicForm(java.util.Map<java.lang.String,java.lang.String> data, java.util.Map<java.lang.String,java.util.List<ValidationError>> errors, java.util.Optional<DynamicForm.Dynamic> value, MessagesApi messagesApi, Formatters formatters, javax.validation.Validator validator)
Map<String,List<ValidationError>>
with a simple List<ValidationError>
.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.validator
- the validator 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.@Deprecated public java.util.Map<java.lang.String,java.lang.String> data()
data
in class Form<DynamicForm.Dynamic>
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 ValidationError error(java.lang.String key)
getError(String)
instead.error
in class Form<DynamicForm.Dynamic>
key
- the field name associated with the error.public java.util.Optional<ValidationError> getError(java.lang.String key)
getError
in class Form<DynamicForm.Dynamic>
key
- the field name associated with the error.public void reject(java.lang.String key, java.lang.String error, java.util.List<java.lang.Object> args)
withError(String, String, List)
instead.reject
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, java.util.List<java.lang.Object> args)
withError
in class Form<DynamicForm.Dynamic>
key
- the error keyerror
- the error messageargs
- the error arguments@Deprecated public void reject(java.lang.String key, java.lang.String error)
withError(String, String)
instead.reject
in class Form<DynamicForm.Dynamic>
key
- the error keyerror
- the error messagepublic DynamicForm withError(java.lang.String key, java.lang.String error)
withError
in class Form<DynamicForm.Dynamic>
key
- the error keyerror
- the error message