title: Ajax dynamically adding textbox is not working in PrimeFaces v3.5
body: <p>My <code>h:form</code> contains a <code>p:selectOneMenu</code> component, which has two values single and multiple. The <code>h:form</code> also contains a default <code>p:inputText</code>. My objective is to add multiple <code>p:inputText</code> component only when value multiple is selected. Please see the attached screenshot-
  <img src="https://i.stack.imgur.com/BZhH5.png" alt="enter image description here"></p>
  
  <p>Below is my view, which suppose to send <code>ajax</code> request, whenever icon button is clicked-</p>
  
  <pre><code>&lt;h:form&gt;
      &lt;p:panel header="Dynamically Add textbox"&gt;
          &lt;p:selectOneMenu id="runType" value="#{repeateRun.runType}"&gt;
              &lt;f:selectItems value="#{repeateRun.runList}" var="runType" itemLabel="#{runType}" itemValue="#{runType}" /&gt;
              &lt;p:ajax update="outPanel" listener="#{repeateRun.renderComponent}" /&gt;
          &lt;/p:selectOneMenu&gt;
          &lt;h:panelGrid id="runList"&gt;
              &lt;ui:repeat value="#{repeateRun.runs}" var="run"&gt;
                  &lt;p:inputText value="#{run.runValue}" /&gt;
              &lt;/ui:repeat&gt;
          &lt;/h:panelGrid&gt;
          &lt;p:outputPanel id="outPanel"&gt;
              &lt;p:commandButton update="runList" icon="ui-icon-plusthick" title="Add more" rendered="#{repeateRun.showAddButton}"&gt;
                  &lt;f:ajax render="runList" listener="#{repeateRun.addRun}" /&gt;
              &lt;/p:commandButton&gt;
          &lt;/p:outputPanel&gt;
      &lt;/p:panel&gt;
  &lt;/h:form&gt;
  </code></pre>
  
  <p>The <code>@ViewScoped</code> <code>@ManagedBean</code> RepeateRun is following-</p>
  
  <pre><code>import java.io.Serializable;
  import java.util.ArrayList;
  import java.util.List;
  import javax.annotation.PostConstruct;
  import javax.faces.bean.ManagedBean;
  import javax.faces.bean.ViewScoped;
  import javax.faces.event.ActionEvent;
  @ManagedBean
  @ViewScoped
  public class RepeateRun implements Serializable {
      private static final long serialVersionUID = 1L;
      private List&lt;String&gt; runList;
      private List&lt;Run&gt; runs;
      private int runValue;
      private String runType;
      private boolean showAddButton = false;
      private static final String SINGLE = "Single";
      private static final String MULTIPLE = "Multiple";
      //Note : Getters Setters are removed while putting here
      @PostConstruct
      public void initBean() {
          this.setRunList(this.populateRunList());
          this.setRuns(this.populateRuns());
      }
      public void addRun() {
          if (this.runs == null) {
              this.setRuns(this.populateRuns());
          } else {
              this.runs.add(this.defaultRun());
          }
      }
      public void renderComponent() {
          if (this.getRunType().equals(SINGLE)) {
              this.setShowAddButton(false);
          } else {
              this.setShowAddButton(true);
          }
      }
      private List&lt;String&gt; populateRunList() {
          List&lt;String&gt; runList = new ArrayList&lt;String&gt;();
          runList.add(SINGLE);
          runList.add(MULTIPLE);
          return runList;
      }
      private Run defaultRun() {
          Run defaultRun = new Run();
          defaultRun.setRunValue(1);
          return defaultRun;
      }
      private List&lt;Run&gt; populateRuns() {
          List&lt;Run&gt; runs = new ArrayList&lt;Run&gt;();
          runs.add(this.defaultRun());
          return runs;
      }
  }
  </code></pre>
  
  <p>So after selecting the value Multiple in <code>f:selectItems</code> the plus icon button comes but the button is not invoking attached method i.e. <code>addRun</code>. To confirm the method <code>addRun</code> call after clicking, I put some <code>sysout</code> statements in <code>addRun</code> method. I saw that <code>sysout</code> is not flushed.  At the same time I saw some <code>xml</code> response in the firebug.
  <br/>
  Where is the problem?</p>