title: Richfaces 4 autocomplete component AJAX Value Update
body: <p>Trying to migrate a Richfaces 3.3 project to 4. Got to a rich:suggestionBox component and converting it to a rich:autocomplete component, but having major troubles. </p>
  
  <p>Requirements are: fill in part of the autocomplete, it presents user with suitable options. When the user selects something from the dropdown, the component should update it's value, disable itself, and also calculate/update the default value in a secondary field, which the user is able to edit. So far I have this:</p>
  
  <pre><code>&lt;a4j:jsFunction name="jsFunc"
      execute="autoComplete"
      render="species_name individualUserStr"
      actionListener="#{individualsBean.selectedIndividualElem.assignDefaultNickname}"/&gt;
  
  
  &lt;rich:autocomplete
  autocompleteMethod="#{individualsBean.speciesForBox}"
  mode="cachedAjax"
  layout="table"
  var="sp"
  id="species_name"
  value="#{individualsBean.selectedIndividualElem.userCommonName}"
  fetchValue="#{sp.commonName}"
  disabled="#{individualsBean.selectedIndividualElem.userCommonName != null
      and individualsBean.selectedIndividualElem.userCommonName ne ''}"
  onselectitem="jsFunc()"
  
  &gt;
  ...
  &lt;/rich:autocomplete&gt;
  
  &lt;h:inputText value="#{individualsBean.selectedIndividualElem.ssi.individualUserStr}"
  id="individualUserStr"
  maxlength="28"
  styleClass="inputTextMediumRF"&gt;
  &lt;/h:inputText&gt;
  </code></pre>
  
  <p>Right now, when the user selects something the jsFunc is called, assignDefaultNickname is called and everything works fine, except for the fact that the calculation in assignDefaultNickname, used to determine the value of the secondary field, individualUserStr, depends upon the value of species_name, but species_name is not submitted until I submit the form, so the calculation done in assignDefaultNickname is incorrect.</p>
  
  <p>I need to somehow call the setter on individualsBean.selectedIndividualElem.userCommonName, before assignDefaultNickname is called, but I cannot figure out how to do this. There seems to be problems with AJAX and this autocomplete function; that's part of the reason why I have to use this round-a-bout jsFunction component to even call the method in the first place.</p>
  
  <p>Any suggestions on how to solve this?</p>