title: JSF commandButton not call action
body: <p>I have a <code>jsf form</code> render different inputText and <code>commandButton</code> if <code>viewParam</code> mode not null. Without mode param, first button call to function when click but with mode param, button not call function. It's always submit and make a postback. I want call to function, validate and redirect back.</p>
  
  <pre><code>&lt;h:form style="border-top: solid 1px #DBDBDB"&gt;
      &lt;div class="form-group" style="width: 112px; float: left"&gt;
           Quantity:&amp;nbsp;&lt;h:messages class="messages"/&gt;
              &lt;h:inputText value="#{orderCreateBean.stringQuantity}" styleClass="form-control" style="margin-bottom: 10px" rendered="#{productBean.mode == null}" /&gt;
              &lt;h:commandButton value="Add to Order" action="#{orderCreateBean.addProduct(productBean.pid)}" styleClass="btn btn-primary" rendered="#{productBean.mode == null}"/&gt;
  
              &lt;h:inputText value="#{orderEditBean.stringQuantity}" styleClass="form-control" style="margin-bottom: 10px" rendered="#{productBean.mode != null}" /&gt;
              &lt;h:commandButton value="Add to Edit" action="#{orderEditBean.addSelectedProduct(productBean.pid)}" styleClass="btn btn-primary" rendered="#{productBean.mode != null}" /&gt;
  
  
       &lt;/div&gt;
  
  &lt;/h:form&gt;
  </code></pre>
  
  <p>OrderEditBean.java</p>
  
  <pre><code>public void addSelectedProduct(int pid) {
      boolean valid = false;
      if (session.get("edit_products") != null &amp;&amp; session.get("edit_number") != null) {
          String edit_number = session.get("edit_number").toString();
          List&lt;OrderProductDetails&gt; opds = (List&lt;OrderProductDetails&gt;) session.get("edit_products");
          if (ApplicationHelper.isInteger(stringQuantity)) {
              quantity = Integer.parseInt(stringQuantity);
              if (0 &lt; quantity &amp;&amp; quantity &lt;= 10) {
                  valid = true;
              }
          }
  
          if (!valid) {
              ApplicationHelper.addMessage("Quantity between 1 and 10");
          } else {
              OrderProductDetails opd = new OrderProductDetails();
              opd.setProductId(new Products(pid));
              opd.setQuantity(quantity);
              opds.add(opd);
              session.put("edit_products", opds);
              ApplicationHelper.addMessage("Product added!");
          }
  
          ApplicationHelper.redirect("client/order/edit_products.xhtml?number=" + edit_number, true);
  
      } else {
          ApplicationHelper.addMessage("You are not in update mode!");
          ApplicationHelper.redirect("/client/product/show.xhtml?pid=" + pid, true);
      }
  }
  </code></pre>
  
  <p>OrderCreateBean.java</p>
  
  <pre><code>public void addProduct(int pid) {
      boolean valid = false;
  
      if (ApplicationHelper.isInteger(stringQuantity)) {
          quantity = Integer.parseInt(stringQuantity);
          if (0 &lt; quantity &amp;&amp; quantity &lt;= 10) {
              valid = true;
          }
      }
  
      if (!valid) {
          ApplicationHelper.addMessage("Quantity between 1 and 10");
          ApplicationHelper.redirect("/client/product/show.xhtml?pid=" + pid, true);
          return;
      }
  
      session = SessionHelper.getSessionMap();
      if (session.get("order_product_details") == null) {
          List&lt;OrderProductDetails&gt; opds = new ArrayList&lt;&gt;();
          OrderProductDetails opd = new OrderProductDetails();
          opd.setProductId(new Products(pid));
          opd.setQuantity(quantity);
          opds.add(opd);
          session.put("order_product_details", opds);
      } else {
          boolean exists = false;
          List&lt;OrderProductDetails&gt; opds = (List&lt;OrderProductDetails&gt;) session.get("order_product_details");
          for (OrderProductDetails opd : opds) {
              if (opd.getProductId().getPid() == pid) {
                  opd.setQuantity(opd.getQuantity() + quantity);
                  exists = true;
                  break;
              }
          }
  
          if (!exists) {
              OrderProductDetails opd = new OrderProductDetails();
              opd.setProductId(new Products(pid));
              opd.setQuantity(quantity);
              opds.add(opd);
          }
  
          session.put("order_product_details", opds);
      }
  
      ApplicationHelper.addMessage("Product added!");
      ApplicationHelper.redirect("/client/order/selected_products.xhtml", true);
  }
  </code></pre>