• Settings
    • Locale
    • Change the locale of the datepicker, schedule and client side validation messages.

      Language
      English
      English
      English
      French
      German
      German
      German
      Italian
      Korean
      Spanish
      Catalan
      Dutch
      Portuguese
      Portuguese
      Arabic
      Arabic
      Bulgarian
      Bangla
      Bosnian
      Czech
      Greek
      Estonian
      Persian
      Finnish
      Danish
      Hindi
      Indonesian
      Icelandic
      Croatian
      Japanese
      Hungarian
      Hebrew
      Georgian
      Central Kurdish
      Khmer
      Kyrgyz
      Kazakh
      Lithuanian
      Latvian
      Malay
      Norwegian
      Polish
      Romanian
      Russian
      Slovak
      Slovenian
      Serbian
      Serbian
      Swedish
      Thai
      Turkish
      Ukrainian
      Uzbek
      Vietnamese
      Chinese
      Chinese
  • Resources

AutoComplete

AutoComplete displays suggestions while the input is being type. AutoComplete features various options, customizable content, multiple selection, effects and events.

AutoComplete Tag Documentation

AutoComplete is a component that provides live suggestions while an input is being typed.

NameTypeRequiredDefaultDescription
id String false generated Unique identifier of the component in a namingContainer.
rendered boolean false true Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding UIComponent false generated An EL expression referring to a server side UIComponent instance in a backing bean.
widgetVar String false generated ('widget_' + componentClientId) Name of the client side widget.
accesskey String false Access key to transfer focus to the input element.
active boolean false true When enabled, component is active.
alt String false Alternate textual description of the input field.
appendTo String false @(body) Search expression to append the panel to.
ariaDescribedBy String false Identifies the element(s) that describe the object, enhancing accessibility.
ariaLabelledBy String false
at String false left bottom Position of the panel relative to the target.
autoHighlight boolean false true When enabled, automatically highlights first suggestion.
autoSelection boolean false true When enabled, automatically selects highlighted suggestion.
autocomplete String false Controls browser autocomplete behavior. Possible values are 'on', 'off', and 'new-password'.
cache boolean false false When enabled, caches suggestions on client side.
cacheTimeout int false 300000 Timeout in milliseconds for cached suggestions.
completeEndpoint String false Endpoint URL for REST-based autocomplete.
completeMethod MethodExpression false MethodExpression to provide suggestions for autocomplete functionality.
converter Converter false EL expression resolves to a converter instance or literal converter ID defining a component converter.
converterMessage String false Custom message to display when conversion fails.
dir String false ltr Direction indication for text that does not inherit directionality.
disabled boolean false false Specifies that an element should be disabled.
dropdown boolean false false When enabled, shows dropdown button.
dropdownMode String false Dropdown mode. Options: 'current', 'blank'.
dropdownTabindex String false Tabindex for the dropdown button.
dynamic boolean false false When enabled, loads suggestions dynamically.
emptyMessage String false Message to display when no suggestions are available.
escape boolean false true When enabled, escapes HTML in suggestions.
forceSelection boolean false false When enabled, forces selection from suggestions.
groupBy Object false Property to group suggestions by.
groupByTooltip String false Tooltip text for group headers.
highlightSelector String false CSS selector for highlighting matched text.
immediate boolean false false When set true, process validations logic is executed at apply request values phase for this component.
inputStyle String false Inline style for the input element.
inputStyleClass String false CSS class for the input element.
inputmode String false Specifies the type of data expected in the input, aiding virtual keyboards.
itemLabel String false Property to use for displaying items.
itemStyleClass String false CSS class for each item.
itemValue Object false Property to use for item value.
itemtipAtPosition String false Position of the item tooltip relative to the target.
itemtipMyPosition String false Position of the item tooltip relative to the item.
label String false A localized user presentable name.
lang String false Specifies the language of the element's content.
lazyField String false Field name for lazy model filtering.
lazyModel LazyDataModel false LazyDataModel for lazy loading suggestions.
localValueSet boolean false false Indicates whether the local value of the component has been set.
maxResults int false 2147483647 Maximum number of results to display.
maxlength int false Integer.MIN_VALUE Defines the maximum number of characters allowed in the input.
minQueryLength int false 1 Minimum number of characters to trigger autocomplete query.
moreText String false ... Text to display when there are more results.
multiple boolean false false When enabled, allows multiple selections.
my String false left top Position of the panel relative to the input.
onblur String false Fires when an element loses focus.
onchange String false Fires when the value of an element has been changed.
onclick String false Fires when a mouse click on the element.
oncontextmenu String false Script to execute when the context menu is triggered.
oncopy String false Script to execute when content is copied from the element.
oncut String false Script to execute when content is cut from the element.
ondblclick String false Fires when a mouse double-click on the element.
ondrag String false Script to execute when an element is dragged.
ondragend String false Script to execute at the end of a drag operation.
ondragenter String false Script to execute when a dragged element enters a valid drop target.
ondragleave String false Script to execute when a dragged element leaves a valid drop target.
ondragover String false Script to execute when a dragged element is over a valid drop target.
ondragstart String false Script to execute at the start of a drag operation.
ondrop String false Script to execute when a dragged element is dropped.
onfocus String false Fires when an element gets focus.
oninput String false Script to execute when the element receives user input.
oninvalid String false Script to execute when the element's value is invalid.
onkeydown String false Fires when a user is pressing a key.
onkeypress String false Fires when a user presses a key.
onkeyup String false Fires when a user releases a key.
onmousedown String false Fires when a mouse button is pressed down on an element.
onmousemove String false Fires when the mouse pointer is moving while it is over an element.
onmouseout String false Fires when the mouse pointer moves out of an element.
onmouseover String false Fires when the mouse pointer moves onto an element.
onmouseup String false Fires when a mouse button is released over an element.
onpaste String false Script to execute when content is pasted into the element.
onreset String false Script to execute when the form is reset.
onscroll String false Script to execute when the element is scrolled.
onsearch String false Script to execute when a search is performed.
onselect String false Script to execute when text is selected.
onwheel String false Script to execute when the mouse wheel is used.
panelStyle String false Inline style for the suggestions panel.
panelStyleClass String false CSS class for the suggestions panel.
placeholder String false Specifies a short hint describing the expected value of the input.
queryDelay int false 300 Delay in milliseconds before triggering autocomplete query.
queryEvent String false Event to trigger autocomplete query.
queryMode String false server Query mode. Options: 'server', 'client', 'hybrid'.
readonly boolean false false Specifies that an input field is read-only.
required boolean false false Marks component as required.
requiredMessage String false Custom message to display when the required validation fails.
role String false Defines the role of the element for accessibility purposes.
scrollHeight int false 2147483647 Maximum height in pixels before scrolling is enabled.
selectLimit int false 2147483647 Maximum number of items that can be selected.
showEmptyMessage boolean false true When enabled, shows empty message when no suggestions.
size int false Integer.MIN_VALUE Number of characters used to determine the width of the input element.
style String false Specifies an inline CSS style for an element.
styleClass String false Specifies one or more CSS class names for an element.
submittedValue Object false
tabindex String false Specifies the tab order of an element.
title String false Specifies extra information about an element (displayed as a tooltip).
type String false text Input field type.
unique boolean false false When enabled, prevents duplicate selections.
valid boolean false true Indicates whether the input's value is valid.
validator Validator false A method expression referring to a method validating the input.
validatorMessage String false Custom message to display when validation fails.
value Object false Value of the component.
valueChangeListener ValueChangeListener false A method binding expression referring to a method for handling a valuchangeevent.
var String false Name of the iterator variable used in itemLabel and itemValue.
Loading...
Tag DocumentationNew DocumentationNew Documentation JSDoc
Single
Multiple

Usage


<div class="card ui-fluid ">
    <h:form>
        <p:growl id="msgs" showDetail="true" skipDetailIfEqualsSummary="true"/>

        <h5 class="mt-0">Single</h5>
        <div class="formgrid grid">
            <div class="field col-12 md:col-4">
                <p:outputLabel value="Simple" for="@next"/>
                <p:autoComplete id="acSimple" value="#{autoCompleteView.txt1}"
                                completeMethod="#{autoCompleteView.completeText}" scrollHeight="250"/>
            </div>

            <div class="field col-12 md:col-4">
                <p:outputLabel value="Min Length (3)" for="@next"/>
                <p:autoComplete id="acMinLength" minQueryLength="3" value="#{autoCompleteView.txt2}"
                                completeMethod="#{autoCompleteView.completeText}" effect="fade" scrollHeight="250"/>
            </div>

            <div class="field col-12 md:col-4">
                <p:outputLabel value="Delay(1000)" for="@next"/>
                <p:autoComplete id="acDelay" queryDelay="1000" value="#{autoCompleteView.txt3}"
                                completeMethod="#{autoCompleteView.completeText}" effect="blind" scrollHeight="250"/>
            </div>

            <div class="field col-12 md:col-4">
                <p:outputLabel value="Max Results(5)" for="@next"/>
                <p:autoComplete id="acMaxResults" maxResults="5" value="#{autoCompleteView.txt4}"
                                completeMethod="#{autoCompleteView.completeText}" scrollHeight="250"
                                moreText="more items available">
                    <p:ajax event="moreTextSelect" listener="#{autoCompleteView.onMoreTextSelect}"
                            update="msgs"/>
                </p:autoComplete>
            </div>

            <div class="field col-12 md:col-4">
                <p:outputLabel value="Force Selection" for="@next"/>
                <p:autoComplete id="acForce" forceSelection="true" value="#{autoCompleteView.txt5}"
                                completeMethod="#{autoCompleteView.completeText}" scrollHeight="250"/>
            </div>

            <div class="field col-12 md:col-4">
                <p:outputLabel value="DropDown" for="@next"/>
                <p:autoComplete id="dd" dropdown="true" value="#{autoCompleteView.txt6}"
                            completeMethod="#{autoCompleteView.completeText}" scrollHeight="250"/>
            </div>

            <div class="field col-12 md:col-4">
                <p:outputLabel value="Cache" for="@next"/>
                <p:autoComplete id="cache" cache="true" cacheTimeout="30000" value="#{autoCompleteView.txt7}"
                                completeMethod="#{autoCompleteView.completeText}" scrollHeight="250"/>
            </div>

            <div class="field col-12 md:col-4">
                <p:outputLabel value="Select Event" for="@next"/>
                <p:autoComplete id="event" value="#{autoCompleteView.txt8}"
                                completeMethod="#{autoCompleteView.completeText}" scrollHeight="250">
                    <p:ajax event="itemSelect" listener="#{autoCompleteView.onItemSelect}" update="msgs"/>
                </p:autoComplete>
            </div>

            <div class="field col-12 md:col-4">
                <p:outputLabel value="Pojo" for="@next"/>
                <p:autoComplete id="pojo" value="#{autoCompleteView.country1}"
                                completeMethod="#{autoCompleteView.completeCountry}"
                                var="country" itemLabel="#{country.name}" itemValue="#{country}"
                                converter="#{countryConverter}" forceSelection="true" scrollHeight="250"/>
            </div>

            <div class="field col-12 md:col-4">
                <p:outputLabel value="Pojo (via REST)" for="pojoRest"/>
                <p:autoComplete id="pojoRest" widgetVar="countryPojoRest" value="#{autoCompleteView.country5}"
                                var="country" itemLabel="#{country.displayName}" itemValue="#{country}"
                                converter="#{countryConverter}"
                                completeEndpoint="#{request.contextPath}/rest/country/autocomplete"
                                forceSelection="true"
                                scrollHeight="250"/>
            </div>

            <div class="field col-12 md:col-4">
                <p:outputLabel value="LazyModel" for="lazyModel"/>
                <p:autoComplete id="lazyModel" widgetVar="lazyModel" value="#{autoCompleteView.txt11}"
                                var="customer" itemLabel="#{customer.name}" itemValue="#{customer.name}"
                                lazyModel="#{autoCompleteView.lazyModel}" lazyField="name"
                                forceSelection="true"
                                maxResults="10"/>
            </div>

            <div class="field col-12 md:col-4">
                <p:outputLabel value="Custom Content" for="@next"/>
                <p:autoComplete id="countryCustom" value="#{autoCompleteView.country2}"
                                completeMethod="#{autoCompleteView.completeCountry}"
                                var="country" itemLabel="#{country.name}" itemValue="#{country}"
                                converter="#{countryConverter}" forceSelection="true" scrollHeight="250">
                    <p:column>
                        <span class="flag flag-#{country.code}" style="width: 30px; height: 20px"/>
                        <h:outputText style="vertical-align: middle; margin-left: .5rem" value="#{country.name}"/>
                    </p:column>
                </p:autoComplete>
            </div>

            <div class="field col-12 md:col-4">
                <p:outputLabel value="Itemtip" for="@next"/>
                <p:autoComplete id="itemTip" value="#{autoCompleteView.country3}"
                                completeMethod="#{autoCompleteView.completeCountry}"
                                var="country" itemLabel="#{country.name}" itemValue="#{country}"
                                converter="#{countryConverter}" scrollHeight="250">
                    <f:facet name="itemtip">
                        <h:panelGrid columns="2" cellpadding="5">
                            <f:facet name="header">
                                <span class="flag flag-#{country.code}" style="width: 30px; height: 20px"/>
                            </f:facet>

                            <h:outputText value="Name"/>
                            <h:outputText value="#{country.name}"/>

                            <h:outputText value="Code"/>
                            <h:outputText value="#{country.code}"/>
                        </h:panelGrid>
                    </f:facet>
                </p:autoComplete>
            </div>

            <div class="field col-12 md:col-4">
                <p:outputLabel value="Group" for="@next"/>
                <p:autoComplete id="group" value="#{autoCompleteView.country4}"
                                completeMethod="#{autoCompleteView.completeCountry}"
                                var="country" itemLabel="#{country.name}" itemValue="#{country}"
                                converter="#{countryConverter}" forceSelection="true"
                                groupBy="#{autoCompleteView.getCountryGroup(country)}" escape="false" scrollHeight="250"/>
            </div>

            <div class="field col-12 md:col-4">
                <p:outputLabel value="Footer" for="@next"/>
                <p:autoComplete id="acFooter" value="#{autoCompleteView.txt10}"
                                completeMethod="#{autoCompleteView.completeText}"
                                maxResults="10">
                    <f:facet name="footer">
                        <div class="ui-fluid" style="padding:0.5rem 1rem 1rem 1rem">
                            <p:button value="Add new" onclick="alert('This could open a dialog')"/>
                        </div>
                    </f:facet>
                </p:autoComplete>
            </div>
        </div>

        <h5>Multiple</h5>
        <p:autoComplete id="countries" multiple="true" value="#{autoCompleteView.selectedCountries}"
                        completeMethod="#{autoCompleteView.completeCountry}" showEmptyMessage="false"
                        var="country" itemLabel="#{country.name}" itemValue="#{country}"
                        converter="#{countryConverter}" forceSelection="false" scrollHeight="250">
            <p:column>
                <span class="flag flag-#{country.code}" style="width: 30px; height: 20px" />
                <h:outputText style="vertical-align: middle; margin-left: .5rem" value="#{country.name}"/>
            </p:column>
        </p:autoComplete>
    </h:form>
</div>