Package com.jalios.jcms.taglib.settings
Class BasicSettings<T extends BasicSettings<T>>
- java.lang.Object
-
- com.jalios.jcms.taglib.settings.BasicSettings<T>
-
- Type Parameters:
T
- Type ofControlSettings
- All Implemented Interfaces:
ControlSettings<T>
,java.lang.Cloneable
- Direct Known Subclasses:
AbstractAreaSettings
,AbstractTextSettings
,DurationSettings
,FileSettings
,HiddenSettings
,PasswordSettings
,SelectorSettings
,SqlQuerySettings
,TypeSettings
public abstract class BasicSettings<T extends BasicSettings<T>> extends java.lang.Object implements ControlSettings<T>
Abstract class to be implemented by all Settings classes.
This class provides the common options.- Author:
- ndossantos
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
APPEND
static java.lang.String
ARIA_ATTR_PREFIX
static java.lang.String
ARIA_ATTRIBUTES
static java.lang.String
AUTOFOCUS
static java.lang.String
CLEAR_BUTTON
static java.lang.String
CSS
static java.lang.String
DATA_ATTR_PREFIX
static java.lang.String
DATA_ATTRIBUTES
static java.lang.String
DISABLED
static java.lang.String
HIDE_CLEAR_BUTTON
static java.lang.String
HTML_ATTRIBUTES
static java.lang.String
ID
static java.lang.String
LANGUAGE_CHOOSER
static java.lang.String
MAX_LENGTH
static java.lang.String
NAME
static java.lang.String
PLACEHOLDER
static java.lang.String
PREPEND
static java.lang.String
READONLY
static java.lang.String
REQUIRED
static java.lang.String
TITLE
static java.lang.String
TRIGGER_ACTION
static java.lang.String
TRIGGER_EVENT
static java.lang.String
VALUE
-
Constructor Summary
Constructors Constructor Description BasicSettings()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description T
addOption(java.lang.String optionName, java.lang.Object optionValues)
Adds new option with the specified value(s).T
append(java.lang.String append)
Place an add-on after the control.T
aria(java.lang.String ariaName, java.lang.Object ariaValue)
Add a aria attributes on the control.
The method accepts the aria name with or without the 'aria-' prefix.T
aria(java.util.Map<java.lang.String,java.lang.Object> arias)
Add a map of aria attributes on the control.
The map key is the aria attribute name, and the map value is the aria attribute value.T
autofocus()
Specify that an <input> element should automatically get focus when the page loads.protected void
clearOption()
Removes all current options.T
clone()
Clone the current ControlSettings.T
css(java.lang.String css)
Add CSS classes on the control.T
dataAttribute(java.lang.String dataName, java.lang.Object dataValue)
Add a data attribute on the control.
The method accepts the data name with or without the 'data-' prefix.T
dataAttributes(java.util.Map<java.lang.String,java.lang.Object> dataAttributes)
Add a map of data attributes on the control.
The map key is the data attribute name, and the map value is the data attribute value.T
disable()
Override field disabled.<V> V
getOption(java.lang.String optionName)
Returns the value of the specified option.java.util.Collection<java.lang.String>
getOptionNames()
Returns the names of defined options for the current ControlSettings.protected abstract T
getThis()
Returns the exact type of the this reference.
It's a way to recover the type of thethis
object in a class hierarchy (cf.T
htmlAttributes(java.lang.String htmlAttributes)
Add additional HTML attributes on the control.
Example:T
htmlAttributes(java.util.Map<java.lang.String,java.lang.Object> htmlAttributesMap)
Add a map of HTML attributes on the control.
The map key is the HTML attribute name, and the map value is the HTML attribute value.T
id(java.lang.String id)
Override field id.protected boolean
isChannelReady()
Check if the Channel is ready and available.T
maxLength(int maxLength)
Specify the maximum number of characters allowed in the control.void
merge(ControlSettings<?> settings)
Merge the current ControlSettings options with the options of specified ControlSettings.T
name(java.lang.String name)
Override field name.T
onChange(java.lang.String action)
Bind the "change" event to the given databroker action.
Example:T
onFocusOut(java.lang.String action)
Bind the "focusout" event to the given databroker action.
Example:T
placeholder(java.lang.String placeholder)
Specify a short hint that describes the expected value of a control.T
prepend(java.lang.String prepend)
Place an add-on before the control.T
readonly()
Override field readonly.T
removeOption(java.lang.String optionName)
Removes the specified option.T
require()
Override field required.void
resolveOptions(TypeFieldEntry tfe)
Set options from the specifiedTypeFieldEntry
.T
showLanguageChooser()
Show the button to select the language at the right of the control.protected static <T> java.util.Set<T>
sortSet(java.util.Set<T> set, java.util.Comparator<T> comparator)
Sort the givenSet
according to the givenComparator
.T
title(java.lang.String title)
Add title on the control.protected static java.lang.String[]
toStringArray(Data[] dataArray)
Return an array ofString
s representing the givenData
.protected static java.lang.String[]
toStringArray(Data data, Data... otherDatas)
Deprecated.usetoStringArray(Object, Object...)
insteadprotected static java.lang.String[]
toStringArray(java.lang.Object[] values)
Return an array ofString
s representing the given Object values.protected static java.lang.String[]
toStringArray(java.lang.Object obj, java.lang.Object... otherObjs)
Return an array ofString
s representing the given objects.protected static java.lang.String[]
toStringArray(java.lang.String firstItem, java.lang.String[] otherItems)
Return an array of Strings by concatenating the strings in parameter.
If one of string is null, it is ignored.T
trigger(java.lang.String event, java.lang.String action)
Bind the given event to the specify databroker action.
Example:T
value(java.lang.Object value)
Override field value.-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.jalios.jcms.taglib.settings.ControlSettings
getType
-
-
-
-
Field Detail
-
ID
public static final java.lang.String ID
- See Also:
- Constant Field Values
-
NAME
public static final java.lang.String NAME
- See Also:
- Constant Field Values
-
VALUE
public static final java.lang.String VALUE
- See Also:
- Constant Field Values
-
DISABLED
public static final java.lang.String DISABLED
- See Also:
- Constant Field Values
-
READONLY
public static final java.lang.String READONLY
- See Also:
- Constant Field Values
-
REQUIRED
public static final java.lang.String REQUIRED
- See Also:
- Constant Field Values
-
CSS
public static final java.lang.String CSS
- See Also:
- Constant Field Values
-
TITLE
public static final java.lang.String TITLE
- See Also:
- Constant Field Values
-
HTML_ATTRIBUTES
public static final java.lang.String HTML_ATTRIBUTES
- See Also:
- Constant Field Values
-
DATA_ATTRIBUTES
public static final java.lang.String DATA_ATTRIBUTES
- See Also:
- Constant Field Values
-
ARIA_ATTRIBUTES
public static final java.lang.String ARIA_ATTRIBUTES
- See Also:
- Constant Field Values
-
PLACEHOLDER
public static final java.lang.String PLACEHOLDER
- See Also:
- Constant Field Values
-
AUTOFOCUS
public static final java.lang.String AUTOFOCUS
- See Also:
- Constant Field Values
-
MAX_LENGTH
public static final java.lang.String MAX_LENGTH
- See Also:
- Constant Field Values
-
LANGUAGE_CHOOSER
public static final java.lang.String LANGUAGE_CHOOSER
- See Also:
- Constant Field Values
-
CLEAR_BUTTON
public static final java.lang.String CLEAR_BUTTON
- See Also:
- Constant Field Values
-
HIDE_CLEAR_BUTTON
public static final java.lang.String HIDE_CLEAR_BUTTON
- See Also:
- Constant Field Values
-
PREPEND
public static final java.lang.String PREPEND
- See Also:
- Constant Field Values
-
APPEND
public static final java.lang.String APPEND
- See Also:
- Constant Field Values
-
TRIGGER_EVENT
public static final java.lang.String TRIGGER_EVENT
- See Also:
- Constant Field Values
-
TRIGGER_ACTION
public static final java.lang.String TRIGGER_ACTION
- See Also:
- Constant Field Values
-
DATA_ATTR_PREFIX
public static final java.lang.String DATA_ATTR_PREFIX
- See Also:
- Constant Field Values
-
ARIA_ATTR_PREFIX
public static final java.lang.String ARIA_ATTR_PREFIX
- See Also:
- Constant Field Values
-
-
Method Detail
-
addOption
public T addOption(java.lang.String optionName, java.lang.Object optionValues)
Description copied from interface:ControlSettings
Adds new option with the specified value(s). If the given value isnull
, the option is removed.- Specified by:
addOption
in interfaceControlSettings<T extends BasicSettings<T>>
- Parameters:
optionName
- Option nameoptionValues
- Option value(s)- Returns:
- a reference to this object - used to chain calls
-
getOption
public <V> V getOption(java.lang.String optionName)
Description copied from interface:ControlSettings
Returns the value of the specified option.- Specified by:
getOption
in interfaceControlSettings<T extends BasicSettings<T>>
- Parameters:
optionName
- Option name- Returns:
- Option value
-
removeOption
public T removeOption(java.lang.String optionName)
Description copied from interface:ControlSettings
Removes the specified option.- Specified by:
removeOption
in interfaceControlSettings<T extends BasicSettings<T>>
- Parameters:
optionName
- Option name- Returns:
- a reference to this object - used to chain calls
-
clearOption
protected void clearOption()
Removes all current options.
-
getOptionNames
public java.util.Collection<java.lang.String> getOptionNames()
Description copied from interface:ControlSettings
Returns the names of defined options for the current ControlSettings.- Specified by:
getOptionNames
in interfaceControlSettings<T extends BasicSettings<T>>
- Returns:
Collection
of String representing the option names
-
resolveOptions
public void resolveOptions(TypeFieldEntry tfe)
Description copied from interface:ControlSettings
Set options from the specifiedTypeFieldEntry
.- Specified by:
resolveOptions
in interfaceControlSettings<T extends BasicSettings<T>>
- Parameters:
tfe
-TypeFieldEntry
-
merge
public void merge(ControlSettings<?> settings)
Description copied from interface:ControlSettings
Merge the current ControlSettings options with the options of specified ControlSettings.- Specified by:
merge
in interfaceControlSettings<T extends BasicSettings<T>>
- Parameters:
settings
- ControlSettings to be merged with the current ControlSettings
-
getThis
protected abstract T getThis()
Returns the exact type of the this reference.
It's a way to recover the type of thethis
object in a class hierarchy (cf. getThis "trick").- Returns:
- The exact type of the this reference
-
id
public T id(java.lang.String id)
Override field id. Used for multiple controls in a field.- Parameters:
id
- id to override- Returns:
- a reference to this object - used to chain calls
-
name
public T name(java.lang.String name)
Override field name. Used for multiple controls in a field.
If theID
option has not been set, the id will be generated.- Parameters:
name
- name to override- Returns:
- a reference to this object - used to chain calls
-
value
public T value(java.lang.Object value)
Override field value. Used for multiple controls in a field.- Parameters:
value
- to override- Returns:
- a reference to this object - used to chain calls
-
disable
public T disable()
Override field disabled. Used for multiple controls in a field.- Returns:
- a reference to this object - used to chain calls
-
readonly
public T readonly()
Override field readonly. Used for multiple controls in a field.- Returns:
- a reference to this object - used to chain calls
-
require
public T require()
Override field required. Used for multiple controls in a field.- Returns:
- a reference to this object - used to chain calls
-
css
public T css(java.lang.String css)
Add CSS classes on the control.- Parameters:
css
- CSS classes- Returns:
- a reference to this object - used to chain calls
-
title
public T title(java.lang.String title)
Add title on the control.- Parameters:
title
- the input title- Returns:
- a reference to this object - used to chain calls
- Since:
- jcms-10.0.7
-
dataAttribute
public T dataAttribute(java.lang.String dataName, java.lang.Object dataValue)
Add a data attribute on the control.
The method accepts the data name with or without the 'data-' prefix. Example:<jalios:control settings='new DefaultSettings().dataAttribute("data-jalios-mydata1", "myvalue1").dataAttribute("jalios-mydata2", "myvalue2")' />
This will add data attributes as follows:data-jalios-mydata1="myvalue1" data-jalios-mydata2="myvalue2"
- Parameters:
dataName
- data attribute namedataValue
- data attribute value- Returns:
- a reference to this object - used to chain calls
-
dataAttributes
public T dataAttributes(java.util.Map<java.lang.String,java.lang.Object> dataAttributes)
Add a map of data attributes on the control.
The map key is the data attribute name, and the map value is the data attribute value. Example:<% Map<String, Object> map = new HashMap<String>(); map.put("data-jalios-mydata1", "myvalue1"); map.put("jalios-mydata2", "myvalue2"); %> <jalios:control settings='new DefaultSettings().dataAttributes(map)' />
- Parameters:
dataAttributes
- Map of data attributes- Returns:
- a reference to this object - used to chain calls
- See Also:
dataAttribute(String, Object)
-
aria
public T aria(java.lang.String ariaName, java.lang.Object ariaValue)
Add a aria attributes on the control.
The method accepts the aria name with or without the 'aria-' prefix. Example:<jalios:control settings='new DefaultSettings().aria("aria-label", "myvalue1").dataAttribute("invalid", true)' />
This will add aria attributes as follows:aria-label="myvalue1" aria-invalid="true"
- Parameters:
ariaName
- aria attribute nameariaValue
- aria attribute value- Returns:
- a reference to this object - used to chain calls
-
aria
public T aria(java.util.Map<java.lang.String,java.lang.Object> arias)
Add a map of aria attributes on the control.
The map key is the aria attribute name, and the map value is the aria attribute value. Example:<% Map<String, Object> map = new HashMap<String>(); map.put("aria-label", "myvalue1"); map.put("invalid", true); %> <jalios:control settings='new DefaultSettings().dataAttributes(map)' />
- Parameters:
arias
- Map of aria attributes- Returns:
- a reference to this object - used to chain calls
- See Also:
aria(String, Object)
-
htmlAttributes
public T htmlAttributes(java.lang.String htmlAttributes)
Add additional HTML attributes on the control.
Example:<jalios:control settings='new DefaultSettings().htmlAttributes("dirname=\"myname.dir\" pattern=\"[A-Za-z]{3}\"")' />
- Parameters:
htmlAttributes
- String representing the HTML attributes to be added- Returns:
- a reference to this object - used to chain calls
-
htmlAttributes
public T htmlAttributes(java.util.Map<java.lang.String,java.lang.Object> htmlAttributesMap)
Add a map of HTML attributes on the control.
The map key is the HTML attribute name, and the map value is the HTML attribute value. Example:<% Map<String, Object> map = new HashMap<String>(); map.put("dirname", "myname.dir"); map.put("pattern", "[A-Za-z]{3}"); %> <jalios:control settings='new DefaultSettings().htmlAttributes(map)' />
- Parameters:
htmlAttributesMap
- Map of HTML attributes- Returns:
- a reference to this object - used to chain calls
- See Also:
htmlAttributes(String)
-
placeholder
public T placeholder(java.lang.String placeholder)
Specify a short hint that describes the expected value of a control.- Parameters:
placeholder
- A hint to the user of what can be entered in the control.- Returns:
- a reference to this object - used to chain calls
- See Also:
- HTML <input> element, HTML <textarea> element
-
autofocus
public T autofocus()
Specify that an <input> element should automatically get focus when the page loads.- Returns:
- a reference to this object - used to chain calls
- See Also:
- HTML <input> element, HTML <textarea> element
-
maxLength
public T maxLength(int maxLength)
Specify the maximum number of characters allowed in the control.- Parameters:
maxLength
- The maximum number of characters allowed in the control- Returns:
- a reference to this object - used to chain calls
- See Also:
- HTML <input> element, HTML <textarea> element
-
showLanguageChooser
public T showLanguageChooser()
Show the button to select the language at the right of the control.- Returns:
- a reference to this object - used to chain calls
-
prepend
public T prepend(java.lang.String prepend)
Place an add-on before the control.- Parameters:
prepend
- String representing the add-on to be added- Returns:
- a reference to this object - used to chain calls
- See Also:
- Input groups
-
append
public T append(java.lang.String append)
Place an add-on after the control.- Parameters:
append
- String representing the add-on to be added- Returns:
- a reference to this object - used to chain calls
- See Also:
- Input groups
-
onChange
public T onChange(java.lang.String action)
Bind the "change" event to the given databroker action.
Example:<jalios:field name="mytextfield" label="My Textfield" description="<span class='label label-info'>Reversed string: <em class='reverse-string'></em></span>"> <jalios:control settings='<%= new TextFieldSettings().onChange("reverse") %>' /> </jalios:field> <jalios:javascript> !function ($) { // Action regexp var pattern = /reverse/i; var callback = function(event) { var broker = $.jalios.Event.match(event, 'broker', pattern, true); if (!broker){ return; } // Element var elm = broker.source.currentTarget; broker.options._broked = true; var reverseString = $(elm).val().split('').reverse().join(''); $(elm).closest('.widget-content').find('.help-block .reverse-string').html(reverseString); } var register = function() { // Register to broker $(document).on("jalios:broker", callback); } // Initialization on DOM ready $(document).ready(function($) { register(); }); }(window.jQuery); </jalios:javascript>
- Parameters:
action
- databroker action- Returns:
- a reference to this object - used to chain calls
-
onFocusOut
public T onFocusOut(java.lang.String action)
Bind the "focusout" event to the given databroker action.
Example:<jalios:field name="mytextfield" label="My Textfield" description="<span class='label label-info'>Reversed string: <em class='reverse-string'></em></span>"> <jalios:control settings='<%= new TextFieldSettings().onFocusOut("reverse") %>' /> </jalios:field> <jalios:javascript> !function ($) { // Action regexp var pattern = /reverse/i; var callback = function(event) { var broker = $.jalios.Event.match(event, 'broker', pattern, true); if (!broker){ return; } // Element var elm = broker.source.currentTarget; broker.options._broked = true; var reverseString = $(elm).val().split('').reverse().join(''); $(elm).closest('.widget-content').find('.help-block .reverse-string').html(reverseString); } var register = function() { // Register to broker $(document).on("jalios:broker", callback); } // Initialization on DOM ready $(document).ready(function($) { register(); }); }(window.jQuery); </jalios:javascript>
- Parameters:
action
- databroker action- Returns:
- a reference to this object - used to chain calls
-
trigger
public T trigger(java.lang.String event, java.lang.String action)
Bind the given event to the specify databroker action.
Example:<jalios:field name="mytextfield" label="My Textfield" description="<span class='label label-info'>Reversed string: <em class='reverse-string'></em></span>"> <jalios:control settings='<%= new TextFieldSettings().trigger("change", "reverse") %>' /> </jalios:field> <jalios:javascript> !function ($) { // Action regexp var pattern = /reverse/i; var callback = function(event) { var broker = $.jalios.Event.match(event, 'broker', pattern, true); if (!broker){ return; } // Element var elm = broker.source.currentTarget; broker.options._broked = true; var reverseString = $(elm).val().split('').reverse().join(''); $(elm).closest('.widget-content').find('.help-block .reverse-string').html(reverseString); } var register = function() { // Register to broker $(document).on("jalios:broker", callback); } // Initialization on DOM ready $(document).ready(function($) { register(); }); }(window.jQuery); </jalios:javascript>
- Parameters:
event
- eventaction
- databroker action- Returns:
- a reference to this object - used to chain calls
-
clone
public T clone() throws java.lang.CloneNotSupportedException
Description copied from interface:ControlSettings
Clone the current ControlSettings.- Specified by:
clone
in interfaceControlSettings<T extends BasicSettings<T>>
- Overrides:
clone
in classjava.lang.Object
- Returns:
- the new cloned ControlSettings
- Throws:
java.lang.CloneNotSupportedException
-
isChannelReady
protected boolean isChannelReady()
Check if the Channel is ready and available.- Returns:
true
if the Channel is ready,false
instead
-
toStringArray
protected static java.lang.String[] toStringArray(java.lang.Object[] values)
Return an array ofString
s representing the given Object values.- Parameters:
values
- array of Object values to resolve inString
- Returns:
- array of
String
s
-
toStringArray
protected static java.lang.String[] toStringArray(Data[] dataArray)
Return an array ofString
s representing the givenData
.- Parameters:
dataArray
- array ofData
to resolve in string (data id)- Returns:
- array of
String
s
-
toStringArray
@Deprecated protected static java.lang.String[] toStringArray(Data data, Data... otherDatas)
Deprecated.usetoStringArray(Object, Object...)
insteadTODO Remove at the next major version, because it's replaced bytoStringArray(Object, Object...)
- Parameters:
data
- First Data for which we retrieve the idotherDatas
- other Data which we retrieve the ids- Returns:
- array of Data ids
-
toStringArray
protected static java.lang.String[] toStringArray(java.lang.Object obj, java.lang.Object... otherObjs)
Return an array ofString
s representing the given objects.- Parameters:
obj
- first object to resolve inString
otherObjs
- other objects to resolve inString
- Returns:
- Array of
String
s
-
toStringArray
protected static java.lang.String[] toStringArray(java.lang.String firstItem, java.lang.String[] otherItems)
Return an array of Strings by concatenating the strings in parameter.
If one of string is null, it is ignored.- Parameters:
firstItem
- firstString
otherItems
- otherString
s- Returns:
- Array of
String
s
-
sortSet
protected static <T> java.util.Set<T> sortSet(java.util.Set<T> set, java.util.Comparator<T> comparator)
Sort the givenSet
according to the givenComparator
.- Parameters:
set
-Set
to sortcomparator
-Comparator
that will be used to order this set- Returns:
- The sorted
Set
-
-