Is there a way to "combine" the SelectOneManu and autoComplete feature? When the form is loaded I'd like that input field to display the current value of the bean property, plus ability to select a new value with autoComplete.
Primefaces already provides this already in the autocomplete component. Just look on the demo site. By adding the dropdown="true"
on the autocomplete menu, you enable support for a dropdown. Concretely, follow the following steps to get your results
Set dropdown="true"
on your autocomplete menu. Then set the completeMethod
to correspond to a method on your backing bean that returns a list of the items you want to show up in the dropdown menu.
To preset the value on the autocomplete component, simply initialise the value in the backing bean to whatever you want. Take the following as an example. If you have
<p:autoComplete id="dd" dropdown="true" value="#{yourBackingBean.myVariable}" completeMethod="#{yourBackingBean.loadOptions}" />
In your backing bean, you initialise the myVariable
type during it's declaration
String myVariable = "Desired Value";
If you're going to be populating the dropdown list with a list of complex/POJO types (and as a result, bind the value
attribute to a complex type in the backing bean), you'll need to use the converter based autocomplete component implementation