O'Reilly logo

PrimeFaces Beginner's Guide by K. Siva Prasad Reddy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – using basic AutoComplete

Let us see how to use the AutoComplete component in the Search Users screen to display a list of matching e-mail IDs:

  1. Create a Search Users form with the AutoComplete component to search by e-mail ID:
    <h:form id="searchUserForm">
        <h:panelGrid columns="2">
            
            <p:outputLabel for="searchUser" value="Search Users By Email"/>
            <p:autoComplete id="searchUser" value="#{userController.searchEmail}" 
                
                completeMethod="#{userController.completeEmail}"/>
                
            <p:commandButton action="${userController.searchUsers()}" value="Submit" update="@form"/>
        </h:panelGrid>
    </h:form>
  2. Implement the completeEmail() method to provide suggestions:
    public List<String> completeEmail(String query) { List<String> emails = new ArrayList<String>(); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required