title: Passing parameter to completeMethod of p:autoComplete
body: <p>I'm using the PrimeFaces <code>p:autoComplete</code> widget in a search form of my project. The user can choose how many and which form-elements (search parameters) he wants to include so I need to pass an ID to the <code>completeMethod</code> for each of them. I've tried adding <code>onfocus=".."</code> to pass the object to the bean but that only would be activated when the element first is loaded.</p>
  
  <p>My question: How can I pass an attribute to the <code>completeMethod</code>?</p>
  
  <p>XHTML of the element (simple):</p>
  
  <pre><code>&lt;p:autoComplete value="#{filter.value}" label="dynamic search attribute"
                  completeMethod="#{myBean.complete}" /&gt;
  </code></pre>
  
  <p>The bean (simple):</p>
  
  <pre><code>@Named("myBean")
  public class MyController implements Serializable {
  
      public List&lt;String&gt; complete(String query) {
          List&lt;String&gt; results = new ArrayList&lt;String&gt;();
          // ... code
          return results;
      }
  }
  </code></pre>
  
  <p>In theory this would seem like the perfect solution:</p>
  
  <pre><code>&lt;p:autoComplete value="#{filter.value}" label="dynamic search attribute"
                  completeMethod="#{myBean.complete(filter)}" /&gt;
  </code></pre>
  
  <p>And again the bean:</p>
  
  <pre><code>@Named("myBean")
  public class MyController implements Serializable {
  
      public List&lt;String&gt; complete(String query, FilterObject o) {
          List&lt;String&gt; results = new ArrayList&lt;String&gt;();
          // ... database query based on FilterObject o
          return results;
      }
  }
  </code></pre>