title: struts2 autocomplete
body: <p>I want to create a drop down menu with autocomplete feature. I have a role object with properties roleId, roleDescription. My search box should only autocomplete on roleDescription. I followed this example:<br>
  <a href="http://code.google.com/p/struts2-jquery/wiki/AutocompleterTag" rel="nofollow noreferrer">http://code.google.com/p/struts2-jquery/wiki/AutocompleterTag</a></p>
  
  <p>autocompleter-select.jsp</p>
  
  <pre><code>&lt;sj:autocompleter 
                              id="roles" 
                              name="echo" 
                              list="%{roles}" 
                              listValue="roleDescription" 
                              listKey="roleId" 
                              selectBox="true"
  /&gt;
  </code></pre>
  
  <p>Autocompleter.java</p>
  
  <pre><code>@ParentPackage(value = "com.project.action")
  public class Autocompleter extends BaseAction {
  
  private String term;
  
  @Actions( {
          @Action(value = "/autocompleter-select", results = { @Result(location = "autocompleter-select.jsp", name = "success") }),
          @Action(value = "/autocompleter", results = { @Result(location = "autocompleter.jsp", name = "success") }),
          })
  public String execute() throws Exception {
  
      return SUCCESS;
  }
  
  public void setTerm(String term) {
      this.term = term;
  }
  
  public List&lt;Role&gt; getRoles() {
      System.out.println("getting roles");
      return services.getRoles();
  }
  }
  </code></pre>