title: Command Button Render?
body: <p>I have one command button for task add to cart, it means when items quantity instock is geater than 0 command button will display but if items quantity instock is 0 it doesn't display.
  How can i write one method render with command button for my upon requirement?</p>
  
  <p>Edited</p>
  
  <p>=================================================================================</p>
  
  <p>i post my code attach with question following:
  i write one method in Session Bean select list of Quantity on hand in stock are zero following:</p>
  
  <pre><code>public List&lt;Items&gt; checkItemsInstock(){
          Query query = em.createNamedQuery("Items.findByInstockgtZero");
          query.setParameter("instockgtzero", 0);
  
          return query.getResultList();
  
      }
  </code></pre>
  
  <p>and Namequery is:</p>
  
  <pre><code>@NamedQuery(name = "Items.findByInstockgtZero", query = "SELECT i FROM Items i WHERE i.instock = :instockgtzero")
  </code></pre>
  
  <p>in JSF Managed Bean i wrote a method return list of items , and Quantity on hand are zero</p>
  
  <pre><code>public List&lt;Items&gt; getQuantityOnHand(){
      return itemDAO.checkItemsInstock();
    }
  </code></pre>
  
  <p>and in JSF Page i was rendered h:commandButton is:</p>
  
  <pre><code>&lt;h:commandButton value="add to cart" style="font-size: x-small" action="#{catItemsListController.addtoCart(item)}"  id="addcart" rendered="#{not empty catItemsListController.quantityOnHand}"/&gt;
  </code></pre>
  
  <p>but it not work, all items have QOH is zero or not zero are display CommandButton</p>
  
  <p>i need help !
  Thank you</p>