title: PrimeFaces autoComplete instantiated by custom component does not display suggestions
body: <p>I have a problem when dynamically instantiating a PF 3.4.2 AutoComplete component.
  The component intially renders ok, its value is refreshed on partial processing
  <strong>but</strong> the suggestions are never displayed.</p>
  
  <p>I am instantiating this control the following way :</p>
  
  <pre><code>    AutoComplete ac = (AutoComplete) context.getApplication().createComponent(AutoComplete.COMPONENT_TYPE);
      final String varName = "p";
  
      ValueExpression ve = JSFUtils.createValueExpression("#{minContext.selected.sen}"), Sen.Type);
      ac.setValueExpression("value", ve);
  
      ac.setForceSelection(true);
  
      ac.setVar(varName);
  
      ValueExpression itemLabel = JSFUtils.createValueExpression("#{sc:senLibelle(p)}"), String.class);
      ac.setValueExpression("itemLabel", itemLabel);
  
      ValueExpression itemValue = JSFUtils.createValueExpression("#{" + varName + "}");
      ac.setValueExpression("itemValue", itemValue);
  
      MethodExpression completeMethod = JSFUtils.createMethodExpression("#{senUtils.completeAllSens}", List.class,new Class[]{String.class});
      ac.setCompleteMethod(completeMethod);
  </code></pre>
  
  <p>then adding it to parent control using</p>
  
  <pre><code>    getChildrens().add(ac);
  </code></pre>
  
  <p>The parent component is a derivation of PF PanelGrid. I use this approach successfully to generate various edition panels and it works like a charm. But I can not figure why it does not with autoComplete.</p>
  
  <p>The parent  control looks like :</p>
  
  <pre><code>@FacesComponent(SenatDataTableEntryDetail.SENAT_COMPONENT_TYPE)
  public class SenatDataTableEntryDetail extends PanelGrid {
  
      /** Leaving renderer unchanged, so that PF renderer for PanelGrid is used.
       */
      public static final String SENAT_COMPONENT_FAMILY = "fr.senat.faces.components";
      public static final String SENAT_COMPONENT_TYPE = SENAT_COMPONENT_FAMILY + ".SenatDataTableEntryDetail";
  
      private enum PropertyKeys { mapper, bean; }
  
      @Override
      public void encodeBegin(FacesContext context) throws IOException {
          super.encodeBegin(context);
          addDynamicChildren(context);
      }
  
      @Override
      public boolean getRendersChildren()
      {
          return true;
      }
  
      ...
  
      private Boolean isInitialized() {
          return (Boolean)getStateHelper().eval(SENAT_INITIALIZED,false);
      }
  
      private void setInitialized(Boolean param) {
          getStateHelper().put(SENAT_INITIALIZED, param);
      }
  
      private void addDynamicChildren(FacesContext context)  throws IOException {
          if(isInitialized()) {
              return;
          }
          setInitialized(true);
          /* components are instiated and added as children only once */
      }    
  }
  </code></pre>
  
  <p>It just adds children to the panel grid.</p>
  
  <p>The other aspects of custom component declaration (in taglib and so on) are ok.</p>
  
  <p>The problem doest not seem to be in EL expressions, completeMethod definition, etc. If I include in my test xhtml page an instanciation of the p:autoComplete with the very same parameters, it just works as expected :</p>
  
  <pre><code>    &lt;p:autoComplete value="#{minContext.selected.sen}" forceSelection="true" 
                          var="p" itemLabel="#{sc:senLibelle(p)}" itemValue="#{p}"
                          completeMethod="#{senUtils.completeAllSens}"/&gt;
  </code></pre>
  
  <p>I noticed that the PF AutoComplete component is a bit special as it renders differently
  when a query is detected. See AutoCompleteRenderer source code in <a href="http://primefaces.googlecode.com/files/primefaces-3.4.2.zip" rel="nofollow">http://primefaces.googlecode.com/files/primefaces-3.4.2.zip</a> .</p>
  
  <p>In the "dynamically instantiated" case, the decode method of this component is not called. I failed to find why those last days, but did not succeed.</p>
  
  <p>I look forward for your suggestions on what to check to correct this annoying "bug".</p>