Class Tagify

  • All Implemented Interfaces:
    EventListener, javax.faces.component.behavior.ClientBehaviorHolder, javax.faces.component.EditableValueHolder, javax.faces.component.PartialStateHolder, javax.faces.component.StateHolder, javax.faces.component.TransientStateHolder, javax.faces.component.ValueHolder, javax.faces.event.ComponentSystemEventListener, javax.faces.event.FacesListener, javax.faces.event.SystemEventListenerHolder, org.primefaces.component.api.InputHolder, org.primefaces.component.api.Widget

    public class Tagify
    extends javax.faces.component.html.HtmlInputText
    implements org.primefaces.component.api.Widget, org.primefaces.component.api.InputHolder
    PrimeFaces component for the Tagify JavaScript component (MIT license): yairEO/tagify
    Author:
    XIMA MEDIA GmbH
    • Field Detail

      • DEFAULT_EDIT_TAGS

        public static final Long DEFAULT_EDIT_TAGS
      • DEFAULT_MAX_TAGS

        public static final Long DEFAULT_MAX_TAGS
      • DEFAULT_DROPDOWN_ENABLED

        public static final Long DEFAULT_DROPDOWN_ENABLED
      • DEFAULT_DROPDOWN_MAX_ITEMS

        public static final Long DEFAULT_DROPDOWN_MAX_ITEMS
      • DEFAULT_DUPLICATES

        public static final Boolean DEFAULT_DUPLICATES
      • DEFAULT_ENFORCE_WHITELIST

        public static final Boolean DEFAULT_ENFORCE_WHITELIST
      • DEFAULT_AUTOCOMPLETE_TAGS

        public static final Boolean DEFAULT_AUTOCOMPLETE_TAGS
      • DEFAULT_ADD_TAG_ON_BLUR

        public static final Boolean DEFAULT_ADD_TAG_ON_BLUR
      • DEFAULT_KEEP_INVALID_TAGS

        public static final Boolean DEFAULT_KEEP_INVALID_TAGS
      • DEFAULT_SKIP_INVALID

        public static final Boolean DEFAULT_SKIP_INVALID
      • DEFAULT_LIST_CONVERTER

        public static final Object DEFAULT_LIST_CONVERTER
      • DEFAULT_DROPDOWN_FUZZY_SEARCH

        public static final boolean DEFAULT_DROPDOWN_FUZZY_SEARCH
        See Also:
        Constant Field Values
      • DEFAULT_DROPDOWN_HIGHLIGHT_FIRST

        public static final boolean DEFAULT_DROPDOWN_HIGHLIGHT_FIRST
        See Also:
        Constant Field Values
      • DEFAULT_DROPDOWN_CLOSE_ON_SELECT

        public static final boolean DEFAULT_DROPDOWN_CLOSE_ON_SELECT
        See Also:
        Constant Field Values
    • Constructor Detail

      • Tagify

        public Tagify()
    • Method Detail

      • getEventNames

        public Collection<String> getEventNames()
        Specified by:
        getEventNames in interface javax.faces.component.behavior.ClientBehaviorHolder
        Overrides:
        getEventNames in class javax.faces.component.html.HtmlInputText
      • getFamily

        public String getFamily()
        Overrides:
        getFamily in class javax.faces.component.UIInput
      • getInputClientId

        public String getInputClientId()
        Specified by:
        getInputClientId in interface org.primefaces.component.api.InputHolder
      • getValidatableInputClientId

        public String getValidatableInputClientId()
        Specified by:
        getValidatableInputClientId in interface org.primefaces.component.api.InputHolder
      • getLabelledBy

        public String getLabelledBy()
        Specified by:
        getLabelledBy in interface org.primefaces.component.api.InputHolder
      • setLabelledBy

        public void setLabelledBy​(String labelledBy)
        Specified by:
        setLabelledBy in interface org.primefaces.component.api.InputHolder
      • resolveWidgetVar

        public String resolveWidgetVar()
        Specified by:
        resolveWidgetVar in interface org.primefaces.component.api.Widget
      • getWidgetVar

        public String getWidgetVar()
      • setWidgetVar

        public void setWidgetVar​(String widgetVar)
      • getListConverter

        public Object getListConverter()
        Returns:
        Whether the model (the value expression) uses a String instead of a List. Defaults to false.
      • setListConverter

        public void setListConverter​(Object listConverter)
        Parameters:
        listConverter - A converter that converts between the model representation and the list of tags. This defaults to null, which means the model must a List. You can use this, for example, to use a comma separated string as a model. Note that this is separate from the UIOutput.getConverter(), which converts between a list item and its string representation.
      • getDelimiters

        public String getDelimiters()
        Returns:
        Required string of delimiters - characters for separating tags. The first character is used as default delimiter in the (hidden) original field. Defaults to ,;.
      • setDelimiters

        public void setDelimiters​(String delimiters)
        Parameters:
        delimiters - Required string of delimiters - characters for separating tags. The first character is used as default delimiter in the (hidden) original field.
      • getPattern

        public String getPattern()
        Returns:
        A JavaScript RegExp for validating a tag. You may want to use the start-of-line and end-of-line anchors.
      • setPattern

        public void setPattern​(String pattern)
        Parameters:
        pattern - A JavaScript RegExp for validating a tag. You may want to use the start-of-line and end-of-line anchors.
      • getDropdownClassname

        public String getDropdownClassname()
        Returns:
        Custom class name for the dropdown suggestions select box.
      • setDropdownClassname

        public void setDropdownClassname​(String dropdownClassname)
        Parameters:
        dropdownClassname - Custom class name for the dropdown suggestions select box.
      • getBackspace

        public String getBackspace()
        Returns:
        What should happen when backspace is pressed on an empty input. remove to remove the last tag, none to take no action, or edit to put the last tag in edit mode.
      • setBackspace

        public void setBackspace​(String backspace)
        Parameters:
        backspace - What should happen when backspace is pressed on an empty input. remove to remove the last tag, none to take no action, or edit to put the last tag in edit mode.
      • getMode

        public String getMode()
        You should not use this option. It is experimental and may not work at all.
        Returns:
        Use normal for the default tag input. Use select for single-value dropdown-like select box. Set to mix to allow mixed-content. The pattern setting must be set to some character
      • setMode

        public void setMode​(String mode)
        You should not use this option. It is experimental and may not work at all.
        Parameters:
        mode - Use normal for the default tag input. Use select for single-value dropdown-like select box. Set to mix to allow mixed-content. The pattern setting must be set to some character
      • getEditTags

        public Long getEditTags()
        Returns:
        How many clicks are necessary to edit a tag. 1 for a single click, 2 for a double click, and 0 to disable editing tags.
      • setEditTags

        public void setEditTags​(Long editTags)
        Parameters:
        editTags - How many clicks are necessary to edit a tag. 1 for a single click, 2 for a double click, and 0 to disable editing tags.
      • getExtender

        public String getExtender()
        Returns:
        An optional extender for customizing this tagify component via JavaScript. It must be a JavaScript expression that evaluates to an object. The expression is evaluated in the global window context. It may contain the following callbacks: beforeRender(tagify, cfg) and afterRender(tagify, cfg). The callbacks are passed the current tagify instance and the current widget configuration. The beforeRender callback may modify the cfg options.
      • setExtender

        public void setExtender​(String extender)
        Parameters:
        extender - An optional extender for customizing this tagify component via JavaScript. It must be a JavaScript expression that evaluates to an object. The expression is evaluated in the global window context. It may contain the following callbacks: beforeRender(tagify, cfg) and afterRender(tagify, cfg). The callbacks are passed the current tagify instance and the current widget configuration. The beforeRender callback may modify the cfg options.
      • getMaxTags

        public Long getMaxTags()
        Returns:
        Maximum number of allowed tags. A negative value means no limit.
      • setMaxTags

        public void setMaxTags​(Long maxTags)
        Parameters:
        maxTags - Maximum number of allowed tags. A negative value means no limit.
      • isDuplicates

        public Boolean isDuplicates()
        Returns:
        Whether duplicate tags should be allowed.
      • setDuplicates

        public void setDuplicates​(Boolean duplicates)
        Parameters:
        duplicates - Whether duplicate tags should be allowed.
      • isEnforceWhitelist

        public Boolean isEnforceWhitelist()
        Returns:
        Whether tags not in the whitelist should be disallowed.
      • setEnforceWhitelist

        public void setEnforceWhitelist​(Boolean enforceWhitelist)
        Parameters:
        enforceWhitelist - Whether tags not in the whitelist should be disallowed.
      • isAutocompleteTags

        public Boolean isAutocompleteTags()
        Returns:
        Whether to try and autocomplete the input's value while typing (match from whitelist).
      • setAutocompleteTags

        public void setAutocompleteTags​(Boolean autocompleteTags)
        Parameters:
        autocompleteTags - Whether to try and autocomplete the input's value while typing (match from whitelist).
      • isAddTagOnBlur

        public Boolean isAddTagOnBlur()
        Returns:
        Whether to automatically add the entered text as a tag when a blur event happens.
      • setAddTagOnBlur

        public void setAddTagOnBlur​(Boolean addTagOnBlur)
        Parameters:
        addTagOnBlur - Whether to automatically add the entered text as a tag when a blur event happens.
      • isKeepInvalidTags

        public Boolean isKeepInvalidTags()
        Returns:
        Whether to remove tags which did not pass validation.
      • setKeepInvalidTags

        public void setKeepInvalidTags​(Boolean keepInvalidTags)
        Parameters:
        keepInvalidTags - Whether to remove tags which did not pass validation.
      • getDropdownEnabled

        public Long getDropdownEnabled()
        Returns:
        Minimum number of characters to input to show the suggestions list. A negative number disables the dropdown.
      • setDropdownEnabled

        public void setDropdownEnabled​(Long dropdownEnabled)
        Parameters:
        dropdownEnabled - Minimum number of characters to input to show the suggestions list. A negative number disables the dropdown.
      • getDropdownMaxItems

        public Long getDropdownMaxItems()
        Returns:
        Maximum items to show in the suggestions list dropdown. Must be a positive number, not including zero.
      • setDropdownMaxItems

        public void setDropdownMaxItems​(Long dropdownMaxItems)
        Parameters:
        dropdownMaxItems - Maximum items to show in the suggestions list dropdown. Must be a positive number, not including zero.
      • isSkipInvalid

        public Boolean isSkipInvalid()
        Returns:
        Whether invalid tags are temporarily added before being automatically removed.
      • setSkipInvalid

        public void setSkipInvalid​(Boolean skipInvalid)
        Parameters:
        skipInvalid - Whether invalid tags are temporarily added before being automatically removed.
      • isDropdownFuzzySearch

        public Boolean isDropdownFuzzySearch()
        Returns:
        How to search for matching items in the dropdown list. When true, match all items containing the current search term. When false, match all items beginning with the current search term.
      • setDropdownFuzzySearch

        public void setDropdownFuzzySearch​(Boolean dropdownFuzzySearch)
        Parameters:
        dropdownFuzzySearch - How to search for matching items in the dropdown list. When true, match all items containing the current search term. When false, match all items beginning with the current search term.
      • isDropdownHighlightFirst

        public Boolean isDropdownHighlightFirst()
        Returns:
        When a suggestions list is shown, highlight the first item, and also suggest it in the input. The suggestion can be accepted with right arrow key.
      • setDropdownHighlightFirst

        public void setDropdownHighlightFirst​(Boolean dropdownHighlightFirst)
        Parameters:
        dropdownHighlightFirst - When a suggestions list is shown, highlight the first item, and also suggest it in the input. The suggestion can be accepted with right arrow key.
      • isDropdownCloseOnSelect

        public Boolean isDropdownCloseOnSelect()
        Returns:
        If getDropdownEnabled() is set to 0 (which means always show dropdown on focus): Close the dropdown after selecting an item.
      • setDropdownCloseOnSelect

        public void setDropdownCloseOnSelect​(Boolean dropdownCloseOnSelect)
        Parameters:
        dropdownCloseOnSelect - If getDropdownEnabled() is set to 0 (which means always show dropdown on focus): Close the dropdown after selecting an item.
      • getWhitelist

        public List<?> getWhitelist()
        Returns:
        A list of tags that are allowed. If isEnforceWhitelist() is enabled, any tags not in the whitelist are forbidden. If #isAutocompleteTags() is enabled, tags in the whitelist are suggested to the user via autocomplete.
      • setWhitelist

        public void setWhitelist​(List<?> whitelist)
        Parameters:
        whitelist - A list of tags that are allowed. If isEnforceWhitelist() is enabled, any tags not in the whitelist are forbidden. If #isAutocompleteTags() is enabled, tags in the whitelist are suggested to the user via autocomplete.
      • getInitiallyDisabledTags

        public List<?> getInitiallyDisabledTags()
        Returns:
        A list of tags which, if present in the UIInput.getValue() when rendering this component, are disabled and cannot be edited.
      • setInitiallyDisabledTags

        public void setInitiallyDisabledTags​(List<?> initiallyDisabledTags)
        Parameters:
        initiallyDisabledTags - A list of tags which, if present in the UIInput.getValue() when rendering this component, are disabled and cannot be edited.
      • getBlacklist

        public List<?> getBlacklist()
        Returns:
        A list of tags which are not allowed.
      • setBlacklist

        public void setBlacklist​(List<?> blacklist)
        Parameters:
        blacklist - A list of tags which are not allowed.
      • validateValue

        protected void validateValue​(javax.faces.context.FacesContext context,
                                     Object value)
        Overrides:
        validateValue in class javax.faces.component.UIInput
      • convertTagList

        public List<String> convertTagList​(javax.faces.context.FacesContext context,
                                           List<?> values)
        Parameters:
        context - Current faces context.
        values - Black or whitelist to convert.
        Returns:
        The list of tags, converted to their string representation. When a converted was specified, it is used.