Defaults to AutoCompleteCfg
. Type of the configuration object for this widget.
Creates a new instance of this widget. Please note that you should NOT override this constructor. Instead, override the init method, which is called at the end of the constructor once the instance is created.
The widget configuration to be used for this widget
instance. This widget configuration is usually created on the server by the javax.faces.render.Renderer
for
this component.
Whether the autocomplete is active.
The cache for the results of an autocomplete search.
The set-interval timer ID for the cache timeout.
The configuration of this widget instance. Please note that
no property is guaranteed to be present, you should always check for undefined
before accessing a property.
This is partly because the value of a property is not transmitted from the server to the client when it equals
the default.
Whether the click event is fired on the selected items when a blur
occurs.
Column span count for the options in the overlay panel with the available completion items.
Current option group when creating the options in the overlay with the available completion items.
Current value in the input field where the user can search for completion items.
Currently selected items, when forceSelection
is enabled.
Text currently entered in the input field.
Array of registered listeners invoked when this widget is destroyed. You should normally not use modify this directly, use addDestroyListener instead.
The DOM element for the container with the dropdown suggestions.
Text to display when there is no data to display.
Unbind callback for the hide overlay handler.
The DOM element for the hidden input with the selected value.
The client-side ID of this widget, with all parent naming containers, such as
myForm:myWidget
. This is also the ID of the container HTML element for this widget. In case the widget needs
multiple container elements (such as Paginator), this may also be an array if IDs.
The DOM element for the input element.
When multiple mode is enabled that allows multiple items to be selected: The DOM element of the container with the input element used to enter text and search for an item to select.
If dynamic loading is enabled, whether the content was loaded already.
Whether to use a drop down menu when searching for completion options.
Whether the tab key is currently pressed.
Whether an item was clicked.
The DOM element for the container with the suggestion items.
Whether an item was selected via the enter key.
The DOM elements for the suggestion items.
The DOM element for the tooltip of a suggestion item.
The jQuery instance of the container element of this widget. In case id is an array, it will contain multiple elements. Please note that some widgets have got not DOM elements at all, in this case this will be an empty jQuery instance.
A CSS selector for the container element (or elements, in case id is an array) of
this widget, This is usually an ID selector (that is properly escaped). You can select the container element or
elements like this: $(widget.jqId)
.
The DOM element for the container with multiple selection items.
The DOM element for the overlay panel with the suggestion items.
The client ID of the overlay panel with the suggestion items.
Placeholder shown in the input field when no text is entered.
Whether to suppress the change event when the input's value changes.
Text previously entered in the input field.
Whether an AJAX request for the autocompletion items is currently in progress.
Array of registered listeners invoked when this widget is refreshed. You should normally not use modify this directly, use addRefreshListener instead.
Tracking number to make sure search requests match up in query mode
Unbind callback for the resize handler.
Hint text for screen readers to provide information about the search results.
Unbind callback for the scroll handler.
The DOM element for the autocomplete status ARIA element.
Whether key input events should be ignored currently.
Timeout ID for the timer used to clear the autocompletion cache in regular intervals.
Whether a touch is made on the dropdown button.
Handler for CSS transitions used by this widget.
The name of the widget variables of this widget. The widget variable can be used to
access a widget instance by calling PF('myWidgetVar')
.
The finishing HTML with the wrapper element of the suggestions box.
The starting HTML with the wrapper element of the suggestions box.
Activates search behavior.
Lets you register a listener that is called before the component is destroyed.
When an AJAX call is made and this component is updated, the DOM element is replaced with the newly rendered content. When the element is removed from the DOM by the update, the DOM element is detached from the DOM and all destroy listeners are called. This makes it possible to add listeners from outside the widget code.
If you call this method twice with the same listener, it will be registered twice and later also called twice.
Note that for this to work, you must not override the destroy
method; or if you do, call super
.
Also, after this widget was detached is done, all destroy listeners will be unregistered.
A destroy listener to be registered.
Add the given suggestion item.
Suggestion item to add.
When an AJAX call is made and this component is updated, the DOM element is replaced with the newly rendered content. However, no new instance of the widget is created. Instead, after the DOM element was replaced, all refresh listeners are called. This makes it possible to add listeners from outside the widget code.
If you call this method twice with the same listener, it will be registered twice and later also called twice.
Note that for this to work, you must not override the refresh
method; or if you do, call super
.
Also, after the refresh is done, all refresh listeners will be deregistered. If you added the listeners from
within this widget, consider adding the refresh listeners not only in the init
method, but also again in
the refresh
method after calling super
.
A refresh listener to be registered.
Aligns (positions) the overlay panel that shows the found suggestions.
Appends the overlay panel to the DOM.
Sets up all event listeners for the dropdown menu.
Sets up all event listeners for mouse and click events.
Sets up all keyboard related event listeners.
Sets up all panel event listeners
Sets up all global event listeners for the overlay.
Each widget may have one or several behaviors attached to it. This method calls all attached behaviors for the given event name. In case no such behavior exists, this method does nothing and returns immediately.
A behavior is a way for associating client-side scripts with UI components that opens all sorts of possibilities, including client-side validation, DOM and style manipulation, keyboard handling, and more. When the behavior is triggered, the configured JavaScript gets executed.
Behaviors are often, but not necessarily, AJAX behavior. When triggered, it initiates a request the server
and processes the response once it is received. This enables several features such as updating or replacing
elements dynamically. You can add an AJAX behavior via
<p:ajax event="name" actionListener="#{...}" onstart="..." />
.
The name of an event to call.
Additional configuration that is passed to the AJAX request for the server-side callback.
Adjusts the value of the aria attributes for the given selectable option.
An option for which to set the aria attributes.
Clears the input field.
Clears the cache with the results of an autocomplete search.
Hides suggested items menu.
Localizes the ARIA accessibility labels for the autocomplete.
Deactivates search behavior.
Clears the set-timeout timer for the autocomplete search.
Will be called after an AJAX request if the widget container will be detached.
When an AJAX call is made and this component is updated, the DOM element is replaced with the newly rendered content. When the element is removed from the DOM by the update, the DOM element is detached from the DOM and this method gets called.
Please note that instead of overriding this method, you should consider adding a destroy listener instead via addDestroyListener. This has the advantage of letting you add multiple listeners, and makes it possible to add additional listeners from code outside this widget.
By default, this method just calls all destroy listeners.
Disables the component.
Disables the dropdown menu.
Adds the given text to the ARIA status label element.
Label text to display.
Enables the component.
Enables the dropdown menu.
Fetches the suggestion items for the current query from the server.
Finds and sets the wrapper HTML snippets on this instance.
Wrapper element with the suggestions fetched from the server.
Triggers the behavior for when the input was cleared.
Each widget may have one or several behaviors attached to it. This method returns the callback function for the given event.
Note: Do not call the method directly, the recommended way to invoke a behavior is via callBehavior.
A behavior is a way for associating client-side scripts with UI components that opens all sorts of possibilities, including client-side validation, DOM and style manipulation, keyboard handling, and more. When the behavior is triggered, the configured JavaScript gets executed.
Behaviors are often, but not necessarily, AJAX behavior. When triggered, it initiates a request the server
and processes the response once it is received. This enables several features such as updating or replacing
elements dynamically. You can add an AJAX behavior via
<p:ajax event="name" actionListener="#{...}" onstart="..." />
.
The name of an event for which to retrieve the behavior.
The behavior with the given name, or null
if no such behavior
exists.
Each widget has got a container element, this method returns that container. This container element is usually also the element whose ID is the client-side ID of the JSF component.
The jQuery instance representing the main HTML container element of this widget.
Gets the closest parent form for this widget.
A JQuery instance that either contains the form when found, or an empty JQuery instance when the form could not be found.
Gets the closest parent form ID for this widget lazily so it can be used in AJAX requests.
Either the form ID or undefined
if no form can be found.
Takes the available suggestion items and groups them.
Fired when the browser viewport is resized or scrolled. In Mobile environment we don't want to hider the overlay we want to re-align it. This is because on some mobile browser the popup may force the browser to trigger a resize immediately and close the overlay. See GitHub #7075.
Each widget may have one or several behaviors attached to it. This method checks whether this widget has got at least one behavior associated with given event name.
A behavior is a way for associating client-side scripts with UI components that opens all sorts of possibilities, including client-side validation, DOM and style manipulation, keyboard handling, and more. When the behavior is triggered, the configured JavaScript gets executed.
Behaviors are often, but not necessarily, AJAX behavior. When triggered, it initiates a request the server
and processes the response once it is received. This enables several features such as updating or replacing
elements dynamically. You can add an AJAX behavior via
<p:ajax event="name" actionListener="#{...}" onstart="..." />
.
The name of an event to check.
true
if this widget has the given behavior, false
otherwise.
Hides the panel with the suggestions.
Adjusts the highlighting and aria attributes for the given selectable option.
An option for which to set the aria attributes.
Flag to indicate to highlight or not
A widget class should not declare an explicit constructor, the default constructor provided by this base widget should be used. Instead, override this initialize method which is called after the widget instance was constructed. You can use this method to perform any initialization that is required. For widgets that need to create custom HTML on the client-side this is also the place where you should call your render method.
Please make sure to call the super method first before adding your own custom logic to the init method:
PrimeFaces.widget.MyWidget = PrimeFaces.widget.BaseWidget.extend({
init: function(cfg) {
this._super(cfg);
// custom initialization
}
});
The widget configuration to be used for this widget instance.
This widget configuration is usually created on the server by the javax.faces.render.Renderer
for this
component.
Initializes the cache that stores the retrieved suggestions for a search term.
Invokes the appropriate behavior for when empty message was selected.
Invokes the appropriate behavior for when a suggestion item was selected.
Value of the selected item.
Invokes the appropriate behavior when a suggestion item was unselected.
Value of the unselected item.
Invokes the appropriate behavior for when more text was selected.
Checks if this widget is detached, ie whether the HTML element of this widget is currently contained within the DOM (the HTML body element). A widget may become detached during an AJAX update, and it may remain detached in case the update removed this component from the component tree.
true
if this widget is currently detached, or false
otherwise.
Checks whether the given value is part of the available suggestion items.
A value to check.
true
if clear event should be fired.
Whether the given value matches a value in the list of available suggestion items;
or undefined
if AutoCompleteCfg.forceSelection is set to false
.
Callback for when a key event occurred.
Key event that occurred.
Used in ajax updates, reloads the widget configuration.
When an AJAX call is made and this component is updated, the DOM element is replaced with the newly rendered content. However, no new instance of the widget is created. Instead, after the DOM element was replaced, this method is called with the new widget configuration from the server. This makes it possible to persist client-side state during an update, such as the currently selected tab.
Please note that instead of overriding this method, you should consider adding a refresh listener instead via addRefreshListener. This has the advantage of letting you add multiple listeners, and makes it possible to add additional listeners from code outside this widget.
By default, this method calls all refresh listeners, then reinitializes the widget by calling the init
method.
The new widget configuration from the server.
The value as returned by the init
method, which is often undefined
.
Removes all items if in multiple mode.
Removes the given suggestion item.
Suggestion item to remove.
Removes the widget's script block from the DOM. Currently, the ID of this script block consists of the
client-side ID of this widget with the prefix _s
, but this is subject to change.
The client-side ID of the widget.
Initiates a search with given value, that is, look for matching options and present the options that were found to the user.
Keyword for the search.
Performs a search the same ways as if the user had opened the dropdown menu. Depending on the configured
dropdownMode
, performs the search either with an empty string or with the current value.
Adds the suggestions items in the given wrapper to the local cache of suggestion items.
Wrapper element with the suggestions fetched from the server.
Sets the querying state.
Querying state to set.
Sets up the event listener for the blur event to force a selection, when that feature is enabled.
Binds events for multiple selection mode.
Shows the panel with the suggestions.
Shows the tooltip for the given suggestion item.
Item with a tooltip.
Performs the search for the available suggestion items.
Keyword for the search.
Unbind all panel event listeners
Generated using TypeDoc
PrimeFaces AutoComplete Widget
AutoComplete provides live suggestions while the user is entering text