title: Why is my Java Server Faces HTML dataTable not populating?
body: <p>I'm following the instructions from a book to create a JSF web page.  An init() method that creates an array list.  This list populates the data table, but nothing shows up on the webpage.  I put a logging message in the init method, and no message shows.</p>
  
  <p>EDIT:
  Java 1.8.0_222, Payara 5.193.1, NetBeans 8.2</p>
  
  <p>javaee-web-api-8.0, javax.faces-2.2.7, javaee-endorsed-api-7.0</p>
  
  <p><strong>index.html</strong></p>
  
  <pre><code>&lt;?xml version='1.0' encoding='UTF-8' ?&gt;
  &lt;!DOCTYPE xhtml PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" [&lt;!ENTITY copy "&amp;#169;"&gt;]&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:h="http://xmlns.jcp.org/jsf/html"&gt;
      &lt;h:head&gt;
          &lt;title&gt;Books&lt;/title&gt;
          &lt;h:outputStylesheet library="css" name="books.css"/&gt;
      &lt;/h:head&gt;
      &lt;h:body&gt;
          &lt;div id="wrapper"&gt;
              &lt;header&gt;
                  &lt;h1&gt;Michael's book list&lt;/h1&gt;
              &lt;/header&gt;
              &lt;main&gt;
                  &lt;h1&gt;Edit categories&lt;/h1&gt;
                  &lt;h:form&gt;
                      &lt;h:dataTable value="#{categoryEditor.categories}"
                                   var="cat"&gt;
                          &lt;h:column&gt;
                              &lt;h:commandLink
                                  action="#{categoryEditor.deleteCategory(cat)}"&gt;
                                  &lt;h:graphicImage alt="delete"
                                                  name="Delete.png"
                                                  library="icon/small"
                                                  title="delete"/&gt;
                              &lt;/h:commandLink&gt;
                          &lt;/h:column&gt;
                          &lt;h:column&gt;
                              &lt;h:inputText value="#{cat.name}"/&gt;
                          &lt;/h:column&gt;
                      &lt;/h:dataTable&gt;
                      &lt;h:commandLink styleClass="button"
                                     value="Add category"
                                     action="#{categoryEditor.addCategory}"/&gt;
                      &lt;h:commandButton styleClass="button"
                                       value="Save"
                                       action="#{categoryEditor.save}"/&gt;
                  &lt;/h:form&gt;
              &lt;/main&gt;
              &lt;nav&gt;
                  This is the Navigation
              &lt;/nav&gt;
              &lt;footer&gt;
                  &amp;copy; Michael Muller &lt;!-- &amp;copy refers to the copyright sign 
                  HTML5 doesn't know such entities, so doctype must be enhanced--&gt;
  
                  &lt;h:outputLink value="http://blog.mueller-bruehl.de"&gt;
                      Michael's Blog
                  &lt;/h:outputLink&gt;
  
                  &lt;h:link value="About" outcome="index.xhtml"/&gt;
              &lt;/footer&gt;
          &lt;/div&gt;
      &lt;/h:body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>CategoryEditor.java</strong></p>
  
  <pre><code>package us.potato.books;
  
  import java.io.Serializable;
  import java.util.ArrayList;
  import java.util.List;
  import java.util.logging.Level;
  import java.util.logging.Logger;
  import javax.annotation.PostConstruct;
  import javax.enterprise.context.SessionScoped;
  import javax.inject.Named;
  
  @Named
  @SessionScoped
  public class CategoryEditor implements Serializable{
      private static final long serialVersionUID = 1L;
      private static final Logger _logger = Logger.getLogger("CategoryEditor");
  
      @PostConstruct
      private void init() {
          _categories = new ArrayList&lt;&gt;();
          _categories.add(new Category(){{setId(1); setName("Java");}});
          _categories.add(new Category(){{setId(2); setName("Web");}});
          _logger.log(Level.INFO, "Categories initialized");
      }
  
      private List&lt;Category&gt; _categories;
  
      public List&lt;Category&gt; getCategories() {
          return _categories;
      }
  
      public void setCategories(List&lt;Category&gt; categories) {
          _categories = categories;
      }
  
      public String addCategory(){
          _categories.add(new Category());
          return "";
      }
  
      public String deleteCategory(Category category){
          _categories.remove(category);
          return "";
      }
  
      public String save(){
          String categories = "";
          for (Category category : _categories){
              if(!category.getName().isEmpty()){
                  if (categories.length() &gt; 0){
                      categories += ", ";
                  }
                  categories += category;
              }
          }
          _logger.log(Level.INFO, "Save categories: {0}", categories);
          return "";
      }
  }
  </code></pre>
  
  <p><strong>Category.java</strong></p>
  
  <pre><code>package us.potato.books;
  
  import java.io.Serializable;
  import java.util.ArrayList;
  import java.util.List;
  import java.util.logging.Level;
  import java.util.logging.Logger;
  import javax.annotation.PostConstruct;
  import javax.enterprise.context.SessionScoped;
  import javax.inject.Named;
  
  @Named
  @SessionScoped
  public class CategoryEditor implements Serializable{
      private static final long serialVersionUID = 1L;
      private static final Logger _logger = Logger.getLogger("CategoryEditor");
  
      @PostConstruct
      private void init() {
          _categories = new ArrayList&lt;&gt;();
          _categories.add(new Category(){{setId(1); setName("Java");}});
          _categories.add(new Category(){{setId(2); setName("Web");}});
          _logger.log(Level.INFO, "Categories initialized");
      }
  
      private List&lt;Category&gt; _categories;
  
      public List&lt;Category&gt; getCategories() {
          return _categories;
      }
  
      public void setCategories(List&lt;Category&gt; categories) {
          _categories = categories;
      }
  
      public String addCategory(){
          _categories.add(new Category());
          return "";
      }
  
      public String deleteCategory(Category category){
          _categories.remove(category);
          return "";
      }
  
      public String save(){
          String categories = "";
          for (Category category : _categories){
              if(!category.getName().isEmpty()){
                  if (categories.length() &gt; 0){
                      categories += ", ";
                  }
                  categories += category;
              }
          }
          _logger.log(Level.INFO, "Save categories: {0}", categories);
          return "";
      }
  }
  </code></pre>
  
  <p><strong>pom.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;us.potato&lt;/groupId&gt;
      &lt;artifactId&gt;Books&lt;/artifactId&gt;
      &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
  
      &lt;name&gt;Books&lt;/name&gt;
  
      &lt;properties&gt;
          &lt;endorsed.dir&gt;${project.build.directory}/endorsed&lt;/endorsed.dir&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish&lt;/groupId&gt;
              &lt;artifactId&gt;javax.faces&lt;/artifactId&gt;
              &lt;version&gt;2.2.7&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax&lt;/groupId&gt;
              &lt;artifactId&gt;javaee-web-api&lt;/artifactId&gt;
              &lt;version&gt;8.0&lt;/version&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;version&gt;3.1&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;1.7&lt;/source&gt;
                      &lt;target&gt;1.7&lt;/target&gt;
                      &lt;compilerArguments&gt;
                          &lt;endorseddirs&gt;${endorsed.dir}&lt;/endorseddirs&gt;
                      &lt;/compilerArguments&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.3&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;failOnMissingWebXml&gt;false&lt;/failOnMissingWebXml&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.6&lt;/version&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;phase&gt;validate&lt;/phase&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;copy&lt;/goal&gt;
                          &lt;/goals&gt;
                          &lt;configuration&gt;
                              &lt;outputDirectory&gt;${endorsed.dir}&lt;/outputDirectory&gt;
                              &lt;silent&gt;true&lt;/silent&gt;
                              &lt;artifactItems&gt;
                                  &lt;artifactItem&gt;
                                      &lt;groupId&gt;javax&lt;/groupId&gt;
                                      &lt;artifactId&gt;javaee-endorsed-api&lt;/artifactId&gt;
                                      &lt;version&gt;7.0&lt;/version&gt;
                                      &lt;type&gt;jar&lt;/type&gt;
                                  &lt;/artifactItem&gt;
                              &lt;/artifactItems&gt;
                          &lt;/configuration&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <p><strong>web.xml</strong></p>
  
  <pre><code>&lt;web-app version="4.0" 
           xmlns="http://xmlns.jcp.org/xml/ns/javaee" 
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
           xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
           http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;javax.faces.PROJECT_STAGE&lt;/param-name&gt;
          &lt;param-value&gt;Development&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;javax.faces.webapp.FacesServlet&lt;/servlet-class&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;*.xhtml&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;session-config&gt;
          &lt;session-timeout&gt;
              30
          &lt;/session-timeout&gt;
      &lt;/session-config&gt;
      &lt;welcome-file-list&gt;
          &lt;welcome-file&gt;index.xhtml&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;
  &lt;/web-app&gt;\
  </code></pre>
  
  <p><strong>nb-configuration.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1"&gt;
          &lt;org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion&gt;1.7-web&lt;/org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion&gt;
          &lt;org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server&gt;gfv3ee6&lt;/org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server&gt;
          &lt;org-netbeans-modules-projectapi.jsf_2e_language&gt;Facelets&lt;/org-netbeans-modules-projectapi.jsf_2e_language&gt;
      &lt;/properties&gt;
  &lt;/project-shared-configuration&gt;
  </code></pre>