Package io.mangoo.routing.bindings
Class Form
java.lang.Object
io.mangoo.routing.bindings.Validator
io.mangoo.routing.bindings.Form
- All Implemented Interfaces:
Serializable
- Author:
- svenkubiak
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFile(InputStream inputStream) Adds a file as an InputStream to the formvoidaddValueList(String key, String value) Adds an item to the value listvoiddiscard()Discards the complete formgetBoolean(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 falseRetrieves an optional double value corresponding to the name of the form elementgetFile()Retrieves a single file of the form.getFiles()Retrieves all attachment files of the formRetrieves an optional float value corresponding to the name of the form elementgetInteger(String key) Retrieves an optional integer value corresponding to the name of the form elementRetrieves an optional string value corresponding to the name of the form elementRetrieves a string value corresponding to the name of the form elementgetValueList(String key) Retrieves the value list for a given keyRetrieves 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 scopebooleanvoidkeep()Adds the form values to the flash scopevoidsetSubmitted(boolean submitted) <T> TConverts the current form into a given object classMethods inherited from class io.mangoo.routing.bindings.Validator
addValue, expectDomainName, expectDomainName, expectEmail, expectEmail, expectExactMatch, expectExactMatch, expectFalse, expectFalse, expectIpv4, expectIpv4, expectIpv6, expectIpv6, expectMatch, expectMatch, expectMatch, expectMatch, expectMaxLength, expectMaxLength, expectMaxValue, expectMaxValue, expectMinLength, expectMinLength, expectMinValue, expectMinValue, expectNotNull, expectNotNull, expectNull, expectNull, expectNumeric, expectNumeric, expectRangeLength, expectRangeLength, expectRangeValue, expectRangeValue, expectRegex, expectRegex, expectTrue, expectTrue, expectUrl, expectUrl, expectValue, expectValue, get, getError, getErrors, hasError, hasErrors, invalidate, isValid, setValues
-
Constructor Details
-
Form
public Form()
-
-
Method Details
-
getString
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
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
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
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
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
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
Retrieves all attachment files of the form- Returns:
- List of files or an empty list
-
getFile
Retrieves a single file of the form. If the form has multiple files, the first will be returned- Returns:
- File or null if no file is present
-
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
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
Adds an item to the value list- Parameters:
key- The name of the form elementvalue- The value to store
-
getValueList
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 -
toObject
Converts the current form into a given object class- Type Parameters:
T- Ignored- Parameters:
clazz- The class to convert to- Returns:
- The converted object or null if conversion fails
-
isSubmitted
public boolean isSubmitted() -
setSubmitted
public void setSubmitted(boolean submitted)
-