public class Value
extends java.lang.Object
FormData
.
To set the FormData, one of the following can be used (ordered by priority):
FormData.push(SlingHttpServletRequest, ValueMap, NameNotFoundMode)
FORM_VALUESS_ATTRIBUTE
as the
keyCONTENTPATH_ATTRIBUTE
as the
keyModifier and Type | Field and Description |
---|---|
static java.lang.String |
CONTENTPATH_ATTRIBUTE
Deprecated.
|
static java.lang.String |
FORM_VALUESS_ATTRIBUTE
Deprecated.
|
Constructor and Description |
---|
Value(SlingHttpServletRequest request,
Config config)
Instantiates a new Value.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
get(java.lang.String name)
A shortcut to
get(String, Object) , with empty string as default
value. |
<T> T |
get(java.lang.String name,
java.lang.Class<T> type)
Returns the value for the given name, converted to type T.
|
<T> T |
get(java.lang.String name,
T defaultValue)
Returns the value for the given name, converted to type T.
|
java.lang.String |
getContentValue(java.lang.String name)
A shortcut to
getContentValue(String, Object) , with empty string as
default value. |
<T> T |
getContentValue(java.lang.String name,
java.lang.Class<T> type)
Returns value from the given name, converted to the given type.
|
<T> T |
getContentValue(java.lang.String name,
T defaultValue)
Returns value from the given name, converted to the type of given default
value.
|
boolean |
isSelected(java.lang.String value,
boolean isFieldOptionSelected)
A shortcut of
isSelected(String, String, boolean) , with name is
taken from name property of the config. |
boolean |
isSelected(java.lang.String value,
boolean isFieldOptionSelected,
boolean forceIgnoreFreshness)
A shortcut of
isSelected(String, String, boolean, boolean) , with name is
taken from name property of the config. |
boolean |
isSelected(java.lang.String name,
java.lang.String value,
boolean isFieldOptionSelected)
|
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. |
<T> T |
val(java.lang.String name,
T fieldValue)
Returns the value for the given name, converted to type T.
|
<T> T |
val(T fieldValue)
A shortcut of
val(String, Object) , with name is taken from
name property of the config. |
@Deprecated public static final java.lang.String FORM_VALUESS_ATTRIBUTE
FormData.push(SlingHttpServletRequest, ValueMap, NameNotFoundMode)
instead@Deprecated public static final java.lang.String CONTENTPATH_ATTRIBUTE
FormData.push(SlingHttpServletRequest, ValueMap, NameNotFoundMode)
insteadpublic Value(@Nonnull SlingHttpServletRequest request, @Nonnull Config config)
request
- The request storing the FormDataconfig
- The config of the form field component@Nonnull public java.lang.String get(@CheckForNull java.lang.String name)
get(String, Object)
, with empty string as default
value.name
- The name of the fieldvalue
property, or the given default value, depending on the conditions
described at get(String, Object)
.@Nonnull public <T> T get(@CheckForNull java.lang.String name, @Nonnull T defaultValue)
In the FormData.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 FormData.NameNotFoundMode.IGNORE_FRESHNESS
mode, if the given name is
not found, then the given fieldValue is returned.
If the FormData is null
or ignoreData
property of the config
is true
, this method returns value
property of the config.
T
- The type of the valuename
- The name of the fielddefaultValue
- The default valuevalue
property, or the given default value, depending on the conditions
described above.@CheckForNull public <T> T get(@CheckForNull java.lang.String name, @Nonnull java.lang.Class<T> type)
In the FormData.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 FormData.NameNotFoundMode.IGNORE_FRESHNESS
mode, if the given name is
not found, then the given fieldValue is returned.
If the FormData is null
or ignoreData
property of the config
is true
, this method returns value
property of the config.
T
- The type of the valuename
- The name of the fieldtype
- The class of the typevalue
property, or null
, depending on the conditions described
above.@CheckForNull public <T> T val(@Nonnull T fieldValue)
val(String, Object)
, with name is taken from
name
property of the config.T
- The type of the valuefieldValue
- The value of the fieldnull
, depending on the conditions described at
val(String, Object)
.@CheckForNull public <T> T val(@CheckForNull java.lang.String name, @Nonnull T fieldValue)
In the FormData.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 FormData.NameNotFoundMode.IGNORE_FRESHNESS
mode, if the given name is
not found, then the given fieldValue is returned.
If the FormData is null
or ignoreData
property of the config
is true
, this method returns the given fieldValue.
The key difference compared to get(String, Object)
is that this
method will return the given fieldValue instead of value from value
property of the config.
T
- The type of the valuename
- The name of the fieldfieldValue
- The value of the fieldnull
, depending on the conditions described above.public boolean isSelected(@CheckForNull java.lang.String value, boolean isFieldOptionSelected)
isSelected(String, String, boolean)
, with name is
taken from name
property of the config.value
- The value of the field option to compare againstisFieldOptionSelected
- true
if the field option is selected; false
otherwise.isSelected(String, String, boolean)
.public boolean isSelected(@CheckForNull java.lang.String value, boolean isFieldOptionSelected, boolean forceIgnoreFreshness)
isSelected(String, String, boolean, boolean)
, with name is
taken from name
property of the config.value
- 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.isSelected(String, String, boolean)
.public boolean isSelected(@CheckForNull java.lang.String name, @CheckForNull java.lang.String value, boolean isFieldOptionSelected)
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(@CheckForNull java.lang.String name, @CheckForNull java.lang.String value, boolean isFieldOptionSelected, boolean forceIgnoreFreshness)
true
if the given value of the field option is selected;
false
otherwise.
In the FormData.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 FormData.NameNotFoundMode.IGNORE_FRESHNESS
mode, if the given name is
not found, then the given isFieldOptionSelected is returned.
If the FormData is null
or ignoreData
property of the config
is true
, 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.@Nonnull public java.lang.String getContentValue(@CheckForNull java.lang.String name)
getContentValue(String, Object)
, with empty string as
default value.name
- The name of the field@Nonnull public <T> T getContentValue(@CheckForNull java.lang.String name, @Nonnull T defaultValue)
T
- The type of the valuename
- The name of the fielddefaultValue
- The default value@CheckForNull public <T> T getContentValue(@CheckForNull java.lang.String name, @Nonnull java.lang.Class<T> type)
T
- The type of the valuename
- The name of the value to returntype
- The return typenull
if non existing
or can't be converted.Copyright © 2010 - 2020 Adobe. All Rights Reserved