play.data
Class DynamicForm

java.lang.Object
  extended by play.data.Form<DynamicForm.Dynamic>
      extended by play.data.DynamicForm

public class DynamicForm
extends Form<DynamicForm.Dynamic>

A dynamic form. This form is backed by a simple HashMap<String,String>


Nested Class Summary
static class DynamicForm.Dynamic
          Simple data structure used by DynamicForm.
 
Nested classes/interfaces inherited from class play.data.Form
Form.Display, Form.Field
 
Constructor Summary
DynamicForm()
          Creates a new empty dynamic form.
DynamicForm(java.util.Map<java.lang.String,java.lang.String> data, java.util.Map<java.lang.String,java.util.List<ValidationError>> errors, F.Option<DynamicForm.Dynamic> value)
          Creates a new dynamic form.
 
Method Summary
 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()
          Retrieves the actual form data.
 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 value)
          Fille with existing data.
 java.lang.String get(java.lang.String key)
          Gets the concrete value if the submission was a success.
 void reject(java.lang.String key, java.lang.String error)
          Adds an error to this form.
 void reject(java.lang.String key, java.lang.String error, java.util.List<java.lang.Object> args)
          Adds an error to this form.
 
Methods inherited from class play.data.Form
apply, bind, bindFromRequest, discardErrors, errors, errorsAsJson, errorsAsJson, fill, form, form, form, form, form, get, getArgumentsForConstraint, globalError, globalErrors, hasErrors, hasGlobalErrors, name, reject, reject, reject, requestData, toString, value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DynamicForm

public DynamicForm()
Creates a new empty dynamic form.


DynamicForm

public DynamicForm(java.util.Map<java.lang.String,java.lang.String> data,
                   java.util.Map<java.lang.String,java.util.List<ValidationError>> errors,
                   F.Option<DynamicForm.Dynamic> value)
Creates a new dynamic form.

Parameters:
data - the current form data (used to display the form)
errors - the collection of errors associated with this form
value - optional concrete value if the form submission was successful
Method Detail

get

public java.lang.String get(java.lang.String key)
Gets the concrete value if the submission was a success.


data

public java.util.Map<java.lang.String,java.lang.String> data()
Description copied from class: Form
Retrieves the actual form data.

Overrides:
data in class Form<DynamicForm.Dynamic>

fill

public DynamicForm fill(java.util.Map value)
Fille with existing data.


bindFromRequest

public DynamicForm bindFromRequest(java.lang.String... allowedFields)
Binds request data to this form - that is, handles form submission.

Overrides:
bindFromRequest in class Form<DynamicForm.Dynamic>
Returns:
a copy of this form filled with the new data

bindFromRequest

public DynamicForm bindFromRequest(Http.Request request,
                                   java.lang.String... allowedFields)
Binds request data to this form - that is, handles form submission.

Overrides:
bindFromRequest in class Form<DynamicForm.Dynamic>
Returns:
a copy of this form filled with the new data

bind

public 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.

Overrides:
bind in class Form<DynamicForm.Dynamic>
Parameters:
data - data to submit
Returns:
a copy of this form filled with the new data

field

public Form.Field field(java.lang.String key)
Retrieves a field.

Overrides:
field in class Form<DynamicForm.Dynamic>
Parameters:
key - field name
Returns:
the field - even if the field does not exist you get a field

error

public ValidationError error(java.lang.String key)
Retrieve an error by key.

Overrides:
error in class Form<DynamicForm.Dynamic>

reject

public void reject(java.lang.String key,
                   java.lang.String error,
                   java.util.List<java.lang.Object> args)
Adds an error to this form.

Overrides:
reject in class Form<DynamicForm.Dynamic>
Parameters:
key - the error key
error - the error message
args - the errot arguments

reject

public void reject(java.lang.String key,
                   java.lang.String error)
Adds an error to this form.

Overrides:
reject in class Form<DynamicForm.Dynamic>
Parameters:
key - the error key
error - the error message