Class BasicSettings<T extends BasicSettings<T>>

    • 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 the this 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 specified TypeFieldEntry.
      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 given Set according to the given Comparator.
      T title​(java.lang.String title)
      Add title on the control.
      protected static java.lang.String[] toStringArray​(Data[] dataArray)
      Return an array of Strings representing the given Data.
      protected static java.lang.String[] toStringArray​(Data data, Data... otherDatas)
      Deprecated.
      protected static java.lang.String[] toStringArray​(java.lang.Object[] values)
      Return an array of Strings representing the given Object values.
      protected static java.lang.String[] toStringArray​(java.lang.Object obj, java.lang.Object... otherObjs)
      Return an array of Strings 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
    • Constructor Detail

      • BasicSettings

        public BasicSettings()
    • 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 is null, the option is removed.
        Specified by:
        addOption in interface ControlSettings<T extends BasicSettings<T>>
        Parameters:
        optionName - Option name
        optionValues - 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 interface ControlSettings<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 interface ControlSettings<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 interface ControlSettings<T extends BasicSettings<T>>
        Returns:
        Collection of String representing the option names
      • 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 interface ControlSettings<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 the this 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 the ID 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 name
        dataValue - 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 name
        ariaValue - 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 - event
        action - 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 interface ControlSettings<T extends BasicSettings<T>>
        Overrides:
        clone in class java.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 of Strings representing the given Object values.
        Parameters:
        values - array of Object values to resolve in String
        Returns:
        array of Strings
      • toStringArray

        protected static java.lang.String[] toStringArray​(Data[] dataArray)
        Return an array of Strings representing the given Data.
        Parameters:
        dataArray - array of Data to resolve in string (data id)
        Returns:
        array of Strings
      • toStringArray

        @Deprecated
        protected static java.lang.String[] toStringArray​(Data data,
                                                          Data... otherDatas)
        Deprecated.
        TODO Remove at the next major version, because it's replaced by toStringArray(Object, Object...)
        Parameters:
        data - First Data for which we retrieve the id
        otherDatas - 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 of Strings representing the given objects.
        Parameters:
        obj - first object to resolve in String
        otherObjs - other objects to resolve in String
        Returns:
        Array of Strings
      • 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 - first String
        otherItems - other Strings
        Returns:
        Array of Strings
      • sortSet

        protected static <T> java.util.Set<T> sortSet​(java.util.Set<T> set,
                                                      java.util.Comparator<T> comparator)
        Sort the given Set according to the given Comparator.
        Parameters:
        set - Set to sort
        comparator - Comparator that will be used to order this set
        Returns:
        The sorted Set