title: Primefaces 5: get value not in list from autocomplete
body: <p>is it possible get a value not in list from autocomplete component?
  I must allow to user to choose an element from list or add new element.</p>
  
  <p>My autocmplete is this:</p>
  
  <pre><code>        &lt;p:autoComplete  
          id="auto"
          value="#{bean.myobject}"
          completeMethod="#{bean.autoComplete()}"
          var="myvar"
          converter="myConverter"
          itemValue="#{myvar}"
          itemLabel="#{myvar.description}"&gt;
  
          &lt;p:ajax event="itemSelect" listener="#{bean.handleSelect}"&gt;
          &lt;/p:ajax&gt;
          &lt;p:ajax event="change" listener="#{bean.action}"&gt;
          &lt;/p:ajax&gt;
      &lt;/p:autoComplete&gt;
  </code></pre>
  
  <p>In my bean, handleSelect method works perfectly with object in list.</p>
  
  <p>Action method instead doesn't get value out of list.</p>
  
  <p>Method action is this:</p>
  
  <pre><code>    public void action(AjaxBehaviorEvent e) {
  
      //FIRST SOLUTION
      AutoComplete anAutoComplete = (AutoComplete) e.getComponent();
      String aSelection = anAutoComplete.getValue().toString();
      System.out.println(aSelection);
  
      //SECOND SOLUTION
      FacesContext context = FacesContext.getCurrentInstance();
      UIComponent current = UIComponent.getCurrentComponent(context);
      Map&lt;String, Object&gt; attrMap = current.getAttributes();
      String test = (String) attrMap.get("auto");
      System.out.println(test);
  }
  </code></pre>
  
  <p>Both solution doesn't work (both variable aSelection and test are null).
  Where is my mistake?
  Thanks.</p>