Package de.xima.fc.gui.component.tagify
Class Tagify
- java.lang.Object
-
- javax.faces.component.UIComponent
-
- javax.faces.component.UIComponentBase
-
- javax.faces.component.UIOutput
-
- javax.faces.component.UIInput
-
- javax.faces.component.html.HtmlInputText
-
- de.xima.fc.gui.component.tagify.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Tagify.PropertyKeys
-
Field Summary
Fields Modifier and Type Field Description static String
COMPONENT_FAMILY
static String
COMPONENT_TYPE
static Boolean
DEFAULT_ADD_TAG_ON_BLUR
static Boolean
DEFAULT_AUTOCOMPLETE_TAGS
static String
DEFAULT_BACKSPACE
static String
DEFAULT_DELIMITERS
static String
DEFAULT_DROPDOWN_CLASSNAME
static boolean
DEFAULT_DROPDOWN_CLOSE_ON_SELECT
static Long
DEFAULT_DROPDOWN_ENABLED
static boolean
DEFAULT_DROPDOWN_FUZZY_SEARCH
static boolean
DEFAULT_DROPDOWN_HIGHLIGHT_FIRST
static Long
DEFAULT_DROPDOWN_MAX_ITEMS
static Boolean
DEFAULT_DUPLICATES
static Long
DEFAULT_EDIT_TAGS
static Boolean
DEFAULT_ENFORCE_WHITELIST
static String
DEFAULT_EXTENDER
static Boolean
DEFAULT_KEEP_INVALID_TAGS
static Object
DEFAULT_LIST_CONVERTER
static Long
DEFAULT_MAX_TAGS
static String
DEFAULT_MODE
static String
DEFAULT_PATTERN
static String
DEFAULT_RENDERER
static Boolean
DEFAULT_SKIP_INVALID
static String
STYLE_CLASS
-
Constructor Summary
Constructors Constructor Description Tagify()
-
Method Summary
-
Methods inherited from class javax.faces.component.html.HtmlInputText
getAccesskey, getAlt, getAutocomplete, getDefaultEventName, getDir, getLabel, getLang, getMaxlength, getOnblur, getOnchange, getOnclick, getOndblclick, getOnfocus, getOnkeydown, getOnkeypress, getOnkeyup, getOnmousedown, getOnmousemove, getOnmouseout, getOnmouseover, getOnmouseup, getOnselect, getRole, getSize, getStyle, getStyleClass, getTabindex, getTitle, isDisabled, isReadonly, setAccesskey, setAlt, setAutocomplete, setDir, setDisabled, setLabel, setLang, setMaxlength, setOnblur, setOnchange, setOnclick, setOndblclick, setOnfocus, setOnkeydown, setOnkeypress, setOnkeyup, setOnmousedown, setOnmousemove, setOnmouseout, setOnmouseover, setOnmouseup, setOnselect, setReadonly, setRole, setSize, setStyle, setStyleClass, setTabindex, setTitle
-
Methods inherited from class javax.faces.component.UIInput
addValidator, addValueChangeListener, clearInitialState, compareValues, decode, getConvertedValue, getConverterMessage, getRequiredMessage, getSubmittedValue, getValidator, getValidatorMessage, getValidators, getValue, getValueChangeListener, getValueChangeListeners, isEmpty, isImmediate, isLocalValueSet, isRequired, isValid, markInitialState, processDecodes, processUpdates, processValidators, removeValidator, removeValueChangeListener, resetValue, restoreState, saveState, setConverterMessage, setImmediate, setLocalValueSet, setRequired, setRequiredMessage, setSubmittedValue, setValid, setValidator, setValidatorMessage, setValue, setValueChangeListener, updateModel, validate
-
Methods inherited from class javax.faces.component.UIOutput
getConverter, getLocalValue, setConverter
-
Methods inherited from class javax.faces.component.UIComponentBase
addClientBehavior, addFacesListener, broadcast, encodeBegin, encodeChildren, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientBehaviors, getClientId, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getListenersForEventClass, getParent, getPassThroughAttributes, getRenderer, getRendererType, getRendersChildren, getValueBinding, invokeOnComponent, isRendered, isTransient, processRestoreState, processSaveState, queueEvent, removeFacesListener, restoreAttachedState, saveAttachedState, setId, setParent, setRendered, setRendererType, setTransient, setValueBinding, subscribeToEvent, unsubscribeFromEvent
-
Methods inherited from class javax.faces.component.UIComponent
encodeAll, getClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getNamingContainer, getPassThroughAttributes, getResourceBundleMap, getStateHelper, getStateHelper, getTransientStateHelper, getTransientStateHelper, getValueExpression, initialStateMarked, isCompositeComponent, isInView, isVisitable, popComponentFromEL, processEvent, pushComponentToEL, restoreTransientState, saveTransientState, setInView, setValueExpression, visitTree
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface javax.faces.component.behavior.ClientBehaviorHolder
addClientBehavior, getClientBehaviors
-
-
-
-
Field Detail
-
COMPONENT_FAMILY
public static final String COMPONENT_FAMILY
- See Also:
- Constant Field Values
-
COMPONENT_TYPE
public static final String COMPONENT_TYPE
- See Also:
- Constant Field Values
-
DEFAULT_RENDERER
public static final String DEFAULT_RENDERER
- See Also:
- Constant Field Values
-
DEFAULT_DELIMITERS
public static final String DEFAULT_DELIMITERS
- See Also:
- Constant Field Values
-
DEFAULT_EXTENDER
public static final String DEFAULT_EXTENDER
- See Also:
- Constant Field Values
-
DEFAULT_PATTERN
public static final String DEFAULT_PATTERN
- See Also:
- Constant Field Values
-
DEFAULT_BACKSPACE
public static final String DEFAULT_BACKSPACE
- See Also:
- Constant Field Values
-
DEFAULT_MODE
public static final String DEFAULT_MODE
- See Also:
- Constant Field Values
-
DEFAULT_DROPDOWN_CLASSNAME
public static final String DEFAULT_DROPDOWN_CLASSNAME
- See Also:
- Constant Field Values
-
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
-
STYLE_CLASS
public static final String STYLE_CLASS
- See Also:
- Constant Field Values
-
-
Method Detail
-
getEventNames
public Collection<String> getEventNames()
- Specified by:
getEventNames
in interfacejavax.faces.component.behavior.ClientBehaviorHolder
- Overrides:
getEventNames
in classjavax.faces.component.html.HtmlInputText
-
getFamily
public String getFamily()
- Overrides:
getFamily
in classjavax.faces.component.UIInput
-
getInputClientId
public String getInputClientId()
- Specified by:
getInputClientId
in interfaceorg.primefaces.component.api.InputHolder
-
getValidatableInputClientId
public String getValidatableInputClientId()
- Specified by:
getValidatableInputClientId
in interfaceorg.primefaces.component.api.InputHolder
-
getLabelledBy
public String getLabelledBy()
- Specified by:
getLabelledBy
in interfaceorg.primefaces.component.api.InputHolder
-
setLabelledBy
public void setLabelledBy(String labelledBy)
- Specified by:
setLabelledBy
in interfaceorg.primefaces.component.api.InputHolder
-
resolveWidgetVar
public String resolveWidgetVar()
- Specified by:
resolveWidgetVar
in interfaceorg.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 aList
. Defaults tofalse
.
-
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 aList
. You can use this, for example, to use a comma separated string as a model. Note that this is separate from theUIOutput.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, oredit
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, oredit
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. Useselect
for single-value dropdown-like select box. Set tomix
to allow mixed-content. Thepattern
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
- Usenormal
for the default tag input. Useselect
for single-value dropdown-like select box. Set tomix
to allow mixed-content. Thepattern
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, and0
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, and0
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)
andafterRender(tagify, cfg)
. The callbacks are passed the current tagify instance and the current widget configuration. ThebeforeRender
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)
andafterRender(tagify, cfg)
. The callbacks are passed the current tagify instance and the current widget configuration. ThebeforeRender
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. Whenfalse
, 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. Whentrue
, match all items containing the current search term. Whenfalse
, 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 to0
(which means always show dropdown on focus): Close the dropdown after selecting an item.
-
setDropdownCloseOnSelect
public void setDropdownCloseOnSelect(Boolean dropdownCloseOnSelect)
- Parameters:
dropdownCloseOnSelect
- IfgetDropdownEnabled()
is set to0
(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. IfisEnforceWhitelist()
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 theUIInput.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 classjavax.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.
-
-