Chips is a PrimeFaces component which is used to enter multiple values on an input field. Let's see an example how to use it.
<h:body style="margin-left:30px"> <h2>PrimeFaces Chips example</h2> <h:form> <p:outputLabel for="items" value="Items: " /><br/> <p:chips id="items" value="#{itemsBean.items}"/><br/> <p:commandButton value="Save" icon="ui-icon-check" update=":itemList"/> <br/> </h:form> <br/> <p:outputPanel id="itemList"> <p:repeat value="#{itemsBean.items}" var="item"> <h:outputText value="#{item}"/> <br/> </p:repeat> </p:outputPanel> </h:body>
@ManagedBean @ViewScoped public class ItemsBean { private List<String> items; public List<String> getItems() { return items; } public void setItems(List<String> items) { System.out.println(items); this.items = items; } }
To try examples, run embedded tomcat (configured in pom.xml of example project below):
mvn tomcat7:run-war
Dependencies and Technologies Used: