-
1. Re: autocompleteMethod example
jonleyo Apr 5, 2015 4:45 PM (in response to med.ben)Example for a autocomplete component :
<rich:autocomplete id="auto" autocompleteMethod="#{autoCompleteBean.searchAutoComplete}"
value="#{autoCompleteBean.value}" minChars="2">
<a4j:ajax event="selectitem" execute="@this" render="@this"
listener="#{autoCompleteBean.selectItemListener}" />
</rich:autocomplete>
@ManagedBean
@ViewScoped
public class AutoCompleteBean implements java.io.Serializable {
private static final long serialVersionUID = -8232534836884753440L;
private String value;
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
/**
* Select item autocomplete.
*
* @param event
*/
public void selectItemListener(AjaxBehaviorEvent event) {
System.out.println("select item listener");
}
/**
* Autocomplete.
*
* @param search
* @return
*/
public List<String> searchAutoComplete(String search) {
List<String> lst;
System.out.println("search auto complete");
lst = new ArrayList<String>();
for (int i = 0; i < 10; i++) {
lst.add("auto " + i);
}
return lst;
}
}
-
2. Re: autocompleteMethod example
michpetrov Apr 7, 2015 5:14 AM (in response to jonleyo)Shouldn't you maybe use the parameter for something?
-
3. Re: autocompleteMethod example
jonleyo Apr 7, 2015 1:07 PM (in response to michpetrov)What do you mean? String search? Indeed, I could. Like lst.add("auto " + i); to lst.add(search + i);