public class FormData
extends java.lang.Object
The values are represented as a ValueMap
. The FormData is set at
request scope, where usually it is set by the form component and read by the
field components.
Modifier and Type | Class and Description |
---|---|
static class |
FormData.NameNotFoundMode
The mode on how to handle the scenario when the FormData doesn't have an
entry of a certain name.
|
Modifier and Type | Method and Description |
---|---|
static FormData |
from(SlingHttpServletRequest request)
Returns the current FormData.
|
<T> T |
get(java.lang.String name,
T fieldValue,
java.lang.Class<T> type)
Returns the value for the given name, converted to type T.
|
<T> T |
get(java.lang.String name,
T fieldValue,
T defaultValue)
Returns the value for the given name, converted to type T.
|
FormData.NameNotFoundMode |
getMode()
Returns the mode of the FormData.
|
ValueMap |
getValueMap()
Returns the values.
|
boolean |
isSelected(java.lang.String name,
java.lang.String value,
boolean isFieldOptionSelected)
An overload of
isSelected(String, String, boolean, boolean) where
forceIgnoreFreshness parameter is false . |
boolean |
isSelected(java.lang.String name,
java.lang.String value,
boolean isFieldOptionSelected,
boolean forceIgnoreFreshness)
Returns
true if the given value of the field option is selected;
false otherwise. |
static FormData |
pop(SlingHttpServletRequest request)
Pops the current FormData.
|
static FormData |
push(SlingHttpServletRequest request,
ValueMap values,
FormData.NameNotFoundMode nameNotFoundMode)
Creates a new FormData representing the given values to the request scope.
|
public static FormData push(SlingHttpServletRequest request, ValueMap values, FormData.NameNotFoundMode nameNotFoundMode)
request
- The request to store the valuesvalues
- The values of the FormDatanameNotFoundMode
- The mode when the FormData doesn't have an entry of a certain namepublic static FormData pop(SlingHttpServletRequest request) throws java.lang.IllegalStateException
request
- The request storing the valuesjava.lang.IllegalStateException
- When this method is called before
push(SlingHttpServletRequest, ValueMap, NameNotFoundMode)
public static FormData from(SlingHttpServletRequest request)
request
- The request storing the valuesnull
if there is nonepublic ValueMap getValueMap()
public FormData.NameNotFoundMode getMode()
public <T> T get(java.lang.String name, T fieldValue, java.lang.Class<T> type)
In the NameNotFoundMode#CHECK_FRESHNESS
mode, if the given name is
not found and the FormData is fresh, then the given fieldValue is returned.
Otherwise, null
is returned.
In the NameNotFoundMode#IGNORE_FRESHNESS
mode, if the given name is
not found, then the given fieldValue is returned.
T
- The type of the valuename
- The name of the fieldfieldValue
- The value of the fieldtype
- The class of the typenull
, depending on the conditions described above.public <T> T get(java.lang.String name, T fieldValue, T defaultValue)
In the NameNotFoundMode#CHECK_FRESHNESS
mode, if the given name is
not found and the FormData is fresh, then the given fieldValue is returned.
Otherwise, the given defaultValue is returned.
In the NameNotFoundMode#IGNORE_FRESHNESS
mode, if the given name is
not found, then the given fieldValue is returned.
T
- The type of the valuename
- The name of the fieldfieldValue
- The value of the fielddefaultValue
- The default valuepublic boolean isSelected(java.lang.String name, java.lang.String value, boolean isFieldOptionSelected)
isSelected(String, String, boolean, boolean)
where
forceIgnoreFreshness
parameter is false
.name
- The name of the fieldvalue
- The value of the field option to compare againstisFieldOptionSelected
- true
if the field option is selected; false
otherwise.public boolean isSelected(java.lang.String name, java.lang.String value, boolean isFieldOptionSelected, boolean forceIgnoreFreshness)
true
if the given value of the field option is selected;
false
otherwise.
In the NameNotFoundMode#CHECK_FRESHNESS
mode, if the given name is
not found and the FormData is fresh, then the given isFieldOptionSelected is
returned, false
otherwise.
In the NameNotFoundMode#IGNORE_FRESHNESS
mode, if the given name is
not found, then the given isFieldOptionSelected is returned.
name
- The name of the fieldvalue
- The value of the field option to compare againstisFieldOptionSelected
- true
if the field option is selected; false
otherwise.forceIgnoreFreshness
- true
to force to be FormData.NameNotFoundMode.IGNORE_FRESHNESS
;
false
otherwise."Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"