Note that there are some explanatory texts on larger screens.

plurals
  1. POPrimeFaces auto filter as we type
    primarykey
    data
    text
    <p>I am using PrimeFaces and I need auto filter functionality in the drop down control.</p> <p>My requirement is that as I start typing, the drop down list should be filtered to show only the items that match with the entered characters.</p> <p>I am currently using AutoComplete control and as you can see in the image below, it does NOT do the filtering, but only highlights the entered characters in bold. Is there any property of this control that will help me do this out of the box or do I have to implement it myself? If so, how to do the same?</p> <p><img src="https://i.stack.imgur.com/nsQV5.jpg" alt="enter image description here"></p> <p>Here is the code:</p> <pre><code>&lt;p:autoComplete id="state" label="state" completeMethod="#{patientBean.listStates}" required="true" dropdown="true" forceSelection="TRUE"/&gt; </code></pre> <p><strong>Or, is there any other control that will help me achieve this out of the box?</strong></p> <p>By the way, I am not sure if the following property of AutoComplete control is relevant to this by any chance? Snippet from the PrimeFaces documentation given below:</p> <pre><code>autocomplete null String Controls browser autocomplete behavior. </code></pre> <p><strong>UPDATE</strong> I am using: JSF 2.1.6 PrimeFaces 4.0</p> <p><strong>Code</strong> test.xhtml </p> <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui"&gt; &lt;h:head&gt; &lt;title&gt;&lt;ui:insert name="title"&gt;Test&lt;/ui:insert&gt;&lt;/title&gt; &lt;/h:head&gt; &lt;h:body&gt; &lt;h:form id="createPatientForm"&gt; &lt;h:panelGrid columns="2"&gt; &lt;p:outputLabel value="State*"&gt;&lt;/p:outputLabel&gt; &lt;p:autoComplete id="state" label="State" completeMethod="#{stateBean.listStates}" required="true" dropdown="true" forceSelection="TRUE"/&gt; &lt;/h:panelGrid&gt; &lt;/h:form&gt; &lt;/h:body&gt; &lt;/html&gt; </code></pre> <p><strong>StateBean.java</strong></p> <pre><code>import java.util.ArrayList; import java.util.List; import javax.faces.bean.ManagedBean; @ManagedBean public class StateBean { private String state; public String getState() { return state; } public void setState(String state) { this.state = state; } public List&lt;String&gt; listStates(String district) { List&lt;String&gt; cities = new ArrayList&lt;String&gt;(); cities.add("California"); cities.add("New Jersey"); cities.add("Texas"); return cities; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload