📅  最后修改于: 2021-01-08 04:02:11             🧑  作者: Mango
它是一个输入组件,可在键入输入时提供实时建议。
通过调用采用单个字符串参数的服务器端completeMethod来加载建议。
PrimeFaces提供了组件,该组件用于创建带有建议的文本框。它包括下表中列出的各种属性。
下表包含AutoComplete属性的属性。
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. |
在下面的示例中,我们正在实现组件。本示例包含以下文件。
// autoComplete.xhtml
AutoComplete
PrimeFaces AutoComplete Example
// AutoComplete.java
package com.javatpoint;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
@ManagedBean
public class AutoComplete {
String countryName;
public List countryList() {
ArrayList list = new ArrayList<>();
list.add("India");
list.add("Australia");
list.add("Germany");
list.add("Italy");
list.add("United States");
list.add("Russia");
return list;
}
public String getCountryName() {
return countryName;
}
public void setCountryName(String CountryName) {
this.countryName = CountryName;
}
}
输出: