Reputation: 395
Is there any way to achieve the following requirement:
SelectOneMenu
with autocomplete,I guess it should be a combination of (customized) filtering
, editable
input and server-side validation, but I did not find out how.
Upvotes: 4
Views: 5632
Reputation: 555
The question is old of cource but it will be helpful to others so giving the answer.
Yes it is possible to get them both. Below is the example from the PrimeFaces demo for the editable combobox.
<p:outputLabel for="city" value="Editable: " />
<p:selectOneMenu id="city" value="#{selectOneMenuView.city}" effect="fold" editable="true">
<f:selectItem itemLabel="Select One" itemValue="" />
<f:selectItems value="#{selectOneMenuView.cities}" />
</p:selectOneMenu>
You can add another attribute to this one and get the characteristics of advanced also together with the editable.
<p:outputLabel for="city" value="Editable: " />
<p:selectOneMenu id="city" value="#{selectOneMenuView.city}" effect="fold" editable="true" filter="true" filterMatchMode="startsWith">
<f:selectItem itemLabel="Select One" itemValue="" />
<f:selectItems value="#{selectOneMenuView.cities}" />
</p:selectOneMenu>
And you are done. You got both.
Upvotes: 4