116
PrimeFaces AutoComplete
It is an input component that provides live suggestions while an input is being typed.
Suggestions are loaded by calling a server side completeMethod that takes a single string parameter.
PrimeFaces provides <p:autoComplete> component which is used to create a text box with suggestions. It includes various attribute that are tabled below.
AutoComplete Attributes
The following table contains attributes for the AutoComplete attribute.
Attribute | Default value | Return type | Description |
---|---|---|---|
id | null | String | It is an unique identifier of the component. |
rendered | true | Boolean | It returns boolean value to specify the rendering of the component. |
binding | null | Object | It is used for an el expression that maps to a server side UIComponent instance in a backing bean. |
value | null | Object | It is a value of the component that can be either an EL expression of a literal text. |
converter | null | Object | An el expression or a literal text that defines a converter for the component. |
immediate | false | Boolean | It returns boolean when set true, process validations logic is executed at apply request values phase for this component. |
required | false | Boolean | It is used to marks component as required. |
RequiredMessage | null | String | It is used to set message to be displayed when required field validation fails. |
dropdown | false | Boolean | It enables dropdown mode when set true. |
accesskey | null | String | It is used to set access key that when pressed transfers focus to the input element. |
autocomplete | null | String | It executes autocomplete behavior. |
Lang | null | String | It is used to set language used in the generated markup for this component. |
onclick | null | String | Client side callback to execute when input element is clicked. |
active | true | Boolean | Defines if autocomplete functionality is enabled. |
Example
Here, in the following example, we are implementing <p:autoComplete> component. This example contains the following files.
JSF File
// autoComplete.xhtml
ManagedBean
// AutoComplete.java
Output:
Next TopicPrimeFaces InputTextarea