title: primefaces autocomplete when cleared field giving previuos results of page on clicking submit button
body: <p>I am using an autocomplete tag of prime faces which retrieves results from a database.</p>
  
  <p>The problem is that when I submit the form leaving the autocomplete field empty the results I get on the page are those of the previous request (the previously selected autocomplete value) - it only gets cleared when I refresh the page.</p>
  
  <p>I want that on each submit, without refreshing the browser page, if i clear out the value in the field using backspaces and submit the form it should give the correct result for this particular instance, not previous one. </p>
  
  <p>I am also using some textfields in the jsf page form but those don't have this problem.
  Can anyone offer guidance as to how this problem can be corrected?</p>
  
  <p><strong>EDITED:</strong>
  Code:</p>
  
  <pre><code>&lt;h:form&gt;
    &lt;h:dataTable id="Ressult" value="#{input.searchResults}" var="r"&gt;
      &lt;h:column&gt;#{r.ID}&lt;/h:column&gt;
      &lt;h:column&gt;#{r.Name}&lt;/h:column&gt;
    &lt;/h:dataTable&gt;
    &lt;tr&gt;
      &lt;td&gt;Current Education Level&lt;/td&gt;
      &lt;td&gt;
        &lt;h:panelGrid styleClass="text-box"&gt;
          &lt;p:autoComplete id="education" value="#{input.education}"
          completeMethod="#{input.getautocomplete}" var="a"
          itemLabel="#{a.Name}" itemValue="#{a}"
          converter="edConverter" forceSelection="true" /&gt;
          &lt;p:column&gt;#{a.Name} - #{a.id}&lt;/p:column&gt;
        &lt;/h:panelGrid&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;City&lt;/td&gt;
      &lt;td&gt;
        &lt;h:selectOneMenu id="txtCity" styleClass="select-field"
        value="#{input.cityId}"&gt;
          &lt;f:selectItem itemLabel=" Please Select" itemValue="0"&gt;
          &lt;/f:selectItem&gt;
          &lt;f:selectItems value="#{input.cities}"&gt;&lt;/f:selectItems&gt;
        &lt;/h:selectOneMenu&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Name of Person&lt;/td&gt;
      &lt;td&gt;
        &lt;h:inputText id="txtName" value="#{input.nameOfPerson}"
        styleClass="text-box"&gt;&lt;/h:inputText&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
    &lt;h:commandButton id="btnSearch" value="Search"
    action="#{input.searching}"&gt;
      &lt;f:ajax execute="@form" render="Ressult"&gt;&lt;/f:ajax&gt;
    &lt;/h:commandButton&gt;
  &lt;/h:form&gt;  
  </code></pre>
  
  <p>And here is the bean code:</p>
  
  <pre><code>public class Input 
  {
      private Education education;
      private List&lt;SelectItem&gt; cities;
      private Integer cityId;
      private String nameOfPerson;
      private List&lt;Results&gt; searchResults;
      //getters and setters
  
      public String searching()
      {
           searchResults=dao.getSearchResults(cityId,education,nameOfPerson);
           return "success";
      }
  
      public void autocomplete(String query)
      {
          //AUTOCOMPLTE lIST CODE HERE
      }
  }
  </code></pre>
  
  <p>By update, if you mean new results to be shown when new items selected, then yes - the form should be updated but autocomplete somehow takes the previously selected value and shows results according to that. At least until I refresh the page - only then is autocomplete's previous is removed.</p>