@ManagedBean
@ViewScoped
public class ExampleBean {
private String inputName;
public List<String> nameSuggestions(String enteredValue) {
List<String> matches = new ArrayList<>();
//using data factory for getting suggestions
for (String s : new DefaultNameDataValues().getFirstNames()) {
if (s.toLowerCase().startsWith(enteredValue.toLowerCase())) {
matches.add(s);
}
}
return matches;
}
public String getInputName() {
return inputName;
}
public void setInputName(String inputName) {
System.out.println(inputName);
this.inputName = inputName;
}
}
To try examples, run embedded tomcat (configured in pom.xml of example project below):
mvn tomcat7:run-war
Output
Example Project
Dependencies and Technologies Used:
primefaces 6.1 primefaces
jsf-api 2.2.14:
This is the master POM file for Oracle's Implementation of the JSF 2.2 Specification.
jsf-impl 2.2.14:
This is the master POM file for Oracle's Implementation of the JSF 2.2 Specification.
datafactory 0.8: Library to generate data for testing.