public class Form extends Object implements MangooValidator
| Modifier and Type | Method and Description |
|---|---|
void |
addFile(File file) |
void |
addValue(String key,
String value) |
String |
get(String key)
Retrieves a form value corresponding to the name of the form element
|
Optional<Boolean> |
getBoolean(String key)
Retrieves an optional boolean value corresponding to the name of the form element
0 maps to false
1 maps to true
"true" maps to true
"false" maps to false
|
Optional<Double> |
getDouble(String key)
Retrieves an optional double value corresponding to the name of the form element
|
String |
getError(String fieldName)
Returns the errors message of specific field
|
Optional<File> |
getFile()
Retrieves a single file of the form.
|
List<File> |
getFiles()
Retrieves all attachment files of the form
|
Optional<Float> |
getFloat(String key)
Retrieves an optional float value corresponding to the name of the form element
|
Optional<Integer> |
getInteger(String key)
Retrieves an optional integer value corresponding to the name of the form element
|
Optional<String> |
getString(String key)
Retrieves an optional string value corresponding to the name of the form element
|
Map<String,String> |
getValues()
Retrieves all form submitted values where the key of the map
corresponds to the name of the form element and the value is
the value of the form element
|
boolean |
hasError(String fieldName)
Checks if a given field has a validation error
|
boolean |
hasErrors()
Checks if any field in the validation has an error
|
boolean |
isSubmitted() |
void |
setSubmitted(boolean submitted) |
Validator |
validation()
Returns the validator object for validation methods
|
@Inject public Form(Validator validator)
public Validator validation()
MangooValidatorvalidation in interface MangooValidatorpublic String getError(String fieldName)
MangooValidatorgetError in interface MangooValidatorfieldName - The field to checkpublic boolean hasError(String fieldName)
fieldName - The field name to checkpublic boolean hasErrors()
public String get(String key)
key - The name of the form elementpublic Optional<String> getString(String key)
key - The name of the form elementpublic Optional<Boolean> getBoolean(String key)
key - The name of the form elementpublic Optional<Integer> getInteger(String key)
key - The name of the form elementpublic Optional<Double> getDouble(String key)
key - The name of the form elementpublic Optional<Float> getFloat(String key)
key - The name of the form elementpublic List<File> getFiles()
public Optional<File> getFile()
public Map<String,String> getValues()
public boolean isSubmitted()
public void addFile(File file)
public void setSubmitted(boolean submitted)
Copyright © 2016. All rights reserved.