title: How to print ArrayList in JSF Facelets
body: <p>I have been trying to print the values from an <code>ArrayList&lt;String&gt;</code> in JSF Facelets, but with no luck. The value is getting stored in an ArrayList but the output is blank on the page.</p>
  
  <p>Bean file:</p>
  
  <pre><code>import java.io.Serializable;
  import java.util.ArrayList;
  import javax.faces.bean.ManagedBean;
  import javax.faces.bean.RequestScoped;
  import javax.faces.bean.SessionScoped;
  
  @ManagedBean(name="newCompanyName")
  @SessionScoped
  public class CompanyNames implements Serializable {
  
      private static final long serialVersionUID = 1L;
  
      private ArrayList&lt;String&gt; list = new ArrayList&lt;String&gt;();
  
      private String companyName;
  
      public String getCompanyName() {
          return companyName;
      }
  
      public void setCompanyName(String companyName) {
          this.companyName = companyName;
          list.add(companyName);
          System.out.println("Size of array list is : "+list.size());
  
          for (String number : list) {
              System.out.println("Number = " + number);
          }       
      }
  
      public CompanyNames(String companyName) {
          this.companyName = companyName;
      }
  
  public CompanyNames() {
  }
  }
  </code></pre>
  
  <p>Here is my JSF file from an XHTML 1.0 Transitional file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1" ?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  
   &lt;html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"&gt;
      &lt;h:head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /&gt;
      &lt;title&gt;Insert title here&lt;/title&gt;
      &lt;/h:head&gt;
  
      &lt;h:body&gt; 
          &lt;ui:repeat var="item" value="#{CompanyNames.list}"&gt; 
              &lt;h1&gt;#{item}&lt;/h1&gt; 
          &lt;/ui:repeat&gt; 
      &lt;/h:body&gt;
  &lt;/html&gt;
  </code></pre>