title: How to use ajax with Primefaces components programmatically
body: <p>I'm trying to create Primefaces UIComponents programmatically and somehow I'm not able to get the data to the Backing Bean. Not sure if it's the Ajax or the value I set for the InputText.
  My code that I want to write programmatically:</p>
  
  <pre><code>&lt;p:inputText id="id_test" value="#{myBean.value}"&gt;
      &lt;p:ajax /&gt;
  &lt;/p:inputText&gt;
  </code></pre>
  
  <p>This is how I tried to solve the problem:</p>
  
  <pre><code>private String value; // Getter&amp;Setter
  
  
  public void buildComponent(){
      FacesContext fc = FacesContext.getCurrentInstance();
      Application ap = fc.getApplication();
  
      InputText inputText = (InputText) ap.createComponent(fc, "org.primefaces.component.InputText", "org.primefaces.component.InputTextRenderer")
      inputText.setValue(value);
      inputText.setId("id_test");
  
      AjaxBehavior ajaxBehavior = (AjaxBehavior) ap.createBehavior(AjaxBehavior.BEHAVIOR_ID);
      inputText.addClientBehavior(inputText.getDefaultEventName(), behavior);
  }
  </code></pre>