Package io.mangoo.routing.bindings
Class Form
- java.lang.Object
-
- io.mangoo.routing.bindings.Validator
-
- io.mangoo.routing.bindings.Form
-
- All Implemented Interfaces:
Serializable
public class Form extends Validator
- Author:
- svenkubiak
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Form()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFile(InputStream inputStream)Adds a file as an InputStream to the formvoidaddValueList(String key, String value)Adds an additional item to the value listvoiddiscard()Discards the complete formOptional<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 falseOptional<Double>getDouble(String key)Retrieves an optional double value corresponding to the name of the form elementOptional<InputStream>getFile()Retrieves a single file of the form.List<InputStream>getFiles()Retrieves all attachment files of the formOptional<Float>getFloat(String key)Retrieves an optional float value corresponding to the name of the form elementOptional<Integer>getInteger(String key)Retrieves an optional integer value corresponding to the name of the form elementOptional<String>getString(String key)Retrieves an optional string value corresponding to the name of the form elementStringgetValue(String key)Retrieves a string value corresponding to the name of the form elementList<String>getValueList(String key)Retrieves the value list for a given keyMap<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 elementbooleanisKept()Checks if the form values are to put in the flash scopebooleanisSubmitted()voidkeep()Adds the form values to the flash scopevoidsetSubmitted(boolean submitted)-
Methods inherited from class io.mangoo.routing.bindings.Validator
addValue, expectDomainName, expectDomainName, expectEmail, expectEmail, expectExactMatch, expectExactMatch, expectIpv4, expectIpv4, expectIpv6, expectIpv6, expectMatch, expectMatch, expectMatch, expectMatch, expectMax, expectMax, expectMin, expectMin, expectNumeric, expectNumeric, expectRange, expectRange, expectRegex, expectRegex, expectUrl, expectUrl, expectValue, expectValue, get, getError, getErrors, hasError, hasErrors, invalidate, isValid, setValues, validateFalse, validateFalse, validateNotNull, validateNotNull, validateNull, validateNull, validateTrue, validateTrue
-
-
-
-
Method Detail
-
getString
public Optional<String> getString(String key)
Retrieves an optional string value corresponding to the name of the form element- Parameters:
key- The name of the form element- Returns:
- Optional of String
-
getValue
public String getValue(String key)
Retrieves a string value corresponding to the name of the form element- Parameters:
key- The name of the form element- Returns:
- String with the value of the form element or an empty value if blank
-
getBoolean
public 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- Parameters:
key- The name of the form element- Returns:
- Optional of Boolean
-
getInteger
public Optional<Integer> getInteger(String key)
Retrieves an optional integer value corresponding to the name of the form element- Parameters:
key- The name of the form element- Returns:
- Optional of Integer
-
getDouble
public Optional<Double> getDouble(String key)
Retrieves an optional double value corresponding to the name of the form element- Parameters:
key- The name of the form element- Returns:
- Optional of Double
-
getFloat
public Optional<Float> getFloat(String key)
Retrieves an optional float value corresponding to the name of the form element- Parameters:
key- The name of the form element- Returns:
- Optional of Float
-
getFiles
public List<InputStream> getFiles()
Retrieves all attachment files of the form- Returns:
- List of files or an empty list
-
getFile
public Optional<InputStream> getFile()
Retrieves a single file of the form. If the the form has multiple files, the first will be returned- Returns:
- File or null if no file is present
-
getValues
public 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- Returns:
- Map with Key-Value elements or empty map
-
addFile
public void addFile(InputStream inputStream)
Adds a file as an InputStream to the form- Parameters:
inputStream- The InputStream to add
-
keep
public void keep()
Adds the form values to the flash scope
-
addValueList
public void addValueList(String key, String value)
Adds an additional item to the value list- Parameters:
key- The name of the form elementvalue- The value to store
-
getValueList
public List<String> getValueList(String key)
Retrieves the value list for a given key- Parameters:
key- The name of the form element- Returns:
- A value list with elements
-
isKept
public boolean isKept()
Checks if the form values are to put in the flash scope- Returns:
- True if form values should be put into flash scope, false otherwise
-
discard
public void discard()
Discards the complete form
-
isSubmitted
public boolean isSubmitted()
-
setSubmitted
public void setSubmitted(boolean submitted)
-
-