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 – selecting multiple items using AutoComplete

Let us see how to use the <p:autoComplete> component with multiple selection:

  1. Create the new post form with the AutoComplete component to select multiple tags:
    <p:autoComplete id="newPostTags" value="#{postController.newPost.tags}" 
            completeMethod="#{postController.completeTag}"
            maxResults="10" minQueryLength="2" queryDelay="400" 
            effect="slide"
            var="t" itemLabel="#{t.label}" itemValue="#{t}" 
            converter="tagConverter" multiple="true">
                    
    </p:autoComplete>

What just happened?

We have used the <p:autoComplete> component with multiple selection support by setting the multiple attribute to true. We have also used various other attributes such as maxResults, minQueryLength, queryDelay, forceSelection ...

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