public class Value extends Object
ValueMap
). The values are set at request
scope. Usually the values are set by form component and they are read by
field components.
To set the values, one can set them to the request attribute either using
FORM_VALUESS_ATTRIBUTE
or CONTENTPATH_ATTRIBUTE
.
Modifier and Type | Field and Description |
---|---|
static String |
CONTENTPATH_ATTRIBUTE |
static String |
FORM_VALUESS_ATTRIBUTE |
Constructor and Description |
---|
Value(SlingHttpServletRequest request,
Config config)
Create a new Value.
|
Modifier and Type | Method and Description |
---|---|
String |
get(String name)
A shortcut to
get(String, Object) , with empty string as default
value. |
<T> T |
get(String name,
Class<T> type)
Returns a value for the given name.
|
<T> T |
get(String name,
T defaultValue)
Returns a value for the given name.
|
String |
getContentValue(String name)
A shortcut to
getContentValue(String, Object) , with empty string
as default value. |
<T> T |
getContentValue(String name,
Class<T> type)
Returns value from the given name, converted to the given type.
|
<T> T |
getContentValue(String name,
T defaultValue)
Returns value from the given name, converted to the type of given default
value.
|
boolean |
isSelected(String value,
boolean defaultReturn)
A shortcut of
isSelected(String, String, boolean) , with name is
taken from name property of the config. |
boolean |
isSelected(String name,
String value,
boolean defaultReturn)
Returns
true if the given value is selected;
false otherwise. |
<T> T |
val(String name,
T defaultValue)
Returns a value for the given name.
|
<T> T |
val(T defaultValue)
A shortcut of
val(String, Object) , with name is taken from
name property of the config. |
public static final String FORM_VALUESS_ATTRIBUTE
public static final String CONTENTPATH_ATTRIBUTE
public Value(SlingHttpServletRequest request, Config config)
request
- The sling requestconfig
- The config of the form field componentpublic String get(String name)
get(String, Object)
, with empty string as default
value.name
- the name of the value to returnpublic <T> T get(String name, T defaultValue)
ignoreData
property of the config is true
,
which will return value
property of the config in that case.T
- The type of the named valuename
- The name of the value to returndefaultValue
- The default valuepublic <T> T get(String name, Class<T> type)
ignoreData
property of the config is true
,
which will return value
property of the config in that case.T
- The type of the named valuename
- The name of the value to returntype
- The return typenull
if non existing or can't be converted.public <T> T val(T defaultValue)
val(String, Object)
, with name is taken from
name
property of the config.T
- The type of the named valuedefaultValue
- The default valuepublic <T> T val(String name, T defaultValue)
ignoreData
property of the config is true
,
which will return the given defaultValue in that case.
The key difference compared to get(String, Object)
is that this
method will return the given default value instead of value from
value
property of the config.T
- The type of the named valuename
- The name of the value to returndefaultValue
- The default valuepublic boolean isSelected(String value, boolean defaultReturn)
isSelected(String, String, boolean)
, with name is
taken from name
property of the config.value
- the valuedefaultReturn
- the default return valueignoreData
property of the config is true
.public boolean isSelected(String name, String value, boolean defaultReturn)
true
if the given value is selected;
false
otherwise.
If the resource doesn't exist or ignoreData
property of the
config is true
, the given defaultReturn is returned.
Otherwise, the given value is compared against the value for the given
name.name
- the name of the value propertyvalue
- the valuedefaultReturn
- the default return valueignoreData
property of the config is true
.public String getContentValue(String name)
getContentValue(String, Object)
, with empty string
as default value.name
- the name of the value propertypublic <T> T getContentValue(String name, T defaultValue)
T
- the type of the valuename
- The name of the value propertydefaultValue
- The default valuepublic <T> T getContentValue(String name, 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 © 2006 - 2015 Adobe Systems Incorporated. All Rights Reserved"