In the last example we saw how to use PrimeFaces Chips component. In this example, we will see how to submit chips component's list via Ajax.
<h:body style="margin-left:30px"> <h2>PrimeFaces Chips With Ajax Example</h2> <h:form> <p:outputLabel for="items" value="Items: "/> <br/> <p:chips id="items" value="#{itemsBean.items}"> <p:ajax event="itemSelect" update=":itemList"/> <p:ajax event="itemUnselect" update=":itemList"/> </p:chips> </h:form> <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 = new ArrayList<>(); public List<String> getItems() { return items; } public void setItems(List<String> 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: