title: JSF - Create a simple button for each Object I have in a list
body: <p>At first I wanted to create a new object for each entry in the table of my database and store it in a list. In the xhtml file, I then wanted to create a button for each item from the list.</p>
  <pre><code>private void fillPlist(ArrayList&lt;Product&gt; p) {
      try {
          
          stm = con.createStatement();
          String sql = &quot;select * from products&quot;;
          ResultSet rst;
          rst = stm.executeQuery(sql);
          while (rst.next()) {
              Product pro = new Product(rst.getInt(&quot;productID&quot;), rst.getString(&quot;productName&quot;),rst.getDouble(&quot;productPrice&quot;));
              p.add(pro);
          }
      } catch(SQLException ex) {
          FacesContext.getCurrentInstance().addMessage(null,
                  new FacesMessage(FacesMessage.SEVERITY_ERROR, &quot;SQLException&quot;, ex.getLocalizedMessage()));
          out.println(&quot;Error: &quot; + ex);
          ex.printStackTrace();
      }
      
  }
  public MyBean() {
      System.out.println(&quot;MyBean.&lt;init&gt;...&quot;);
      testp = new ArrayList&lt;Product&gt;();
      fillPlist(testp);
      
      }
  </code></pre>
  <p>I think this should be right and right after that I tried &lt;c:forEach&gt; and &lt;ui:repeat&gt; and nothing happens. Nothing is displayed as if the list was empty. Does anyone knows where the problem is?</p>