Note that there are some explanatory texts on larger screens.

plurals
  1. POJSF not displaying first row, first column data
    primarykey
    data
    text
    <p>I have a very simple page that is displaying canned data. I experienced this problem with data from a DB so I made this simple example and still have the issue. When this page is navigated to for the first time for a session, the first column in the first row shows no data.</p> <p>It doesn't matter if I change the scope to request or session, nor does it make a difference if I use firefox or IE. All I know is that if I reload the page or navigate away and come back it will all of a sudden show my data - until I close all instances of that browser and load up a new one. Then, again, it won't show my data until I reload the page.</p> <p>The question is why does my beloved first title of my first book never show up until i reload the page ("Operating System Concepts" doesn't show, but "Silberschatz" does)?</p> <p>Below is the relevant code.</p> <p>HomePage.java:</p> <pre><code>public class HomePage { private Book[] books; public HomePage() { books = new Book[3]; books[0] = new Book("Operating System Concepts", "Silberschatz"); books[1] = new Book("Learning Sql", "Beaulieu"); books[2] = new Book("Effective Java", "Bloch"); } public Book[] getBooks() { return books; } public void setBooks(Book[] books) { this.books = books; } } </code></pre> <p>Book.java</p> <pre><code>public class Book { private String title; private String author; public Book() {} public Book(String title, String author) { this.title = title; this.author = author; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getAuthor() { return author; } public void setAuthor(String author) { this.author = author; } } </code></pre> <p>home.jsp:</p> <pre><code>&lt;html&gt; &lt;%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %&gt; &lt;%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %&gt; &lt;link href="../css/styles.css" rel="stylesheet" type="text/css" /&gt; &lt;f:loadBundle basename="omitted.for.anonymity.bundle.home" var="msgs"/&gt; &lt;f:view&gt; &lt;body&gt; &lt;h:form&gt; &lt;h:panelGrid columns="2" columnClasses="sideControlColumn,contentColumn"&gt; &lt;f:facet name="header"&gt; &lt;f:subview id="header"&gt; &lt;jsp:include page="header.jsp" /&gt; &lt;/f:subview&gt; &lt;/f:facet&gt; &lt;f:subview id="sideControl" &gt; &lt;jsp:include page="sideControl.jsp" /&gt; &lt;/f:subview&gt; &lt;h:dataTable value="#{homePage.books}" var="book" styleClass="homeTable" rowClasses="evenColumn,oddColumn" &gt; &lt;h:column&gt; &lt;f:facet name="header"&gt; &lt;h:outputText value="#{msgs.columnHeader1}"/&gt; &lt;/f:facet&gt; &lt;h:outputText value="#{book.title}" /&gt; &lt;/h:column&gt; &lt;h:column&gt; &lt;f:facet name="header"&gt; &lt;h:outputText value="#{msgs.columnHeader2}"/&gt; &lt;/f:facet&gt; &lt;h:outputText value="#{book.author}" /&gt; &lt;/h:column&gt; &lt;/h:dataTable&gt; &lt;/h:panelGrid&gt; &lt;/h:form&gt; &lt;/body&gt; &lt;/f:view&gt; &lt;/html&gt; </code></pre> <p>faces-config.xml:</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN" "http://java.sun.com/dtd/web-facesconfig_1_1.dtd"&gt; &lt;faces-config&gt; &lt;navigation-rule&gt; &lt;from-view-id&gt;/pages/login.jsp&lt;/from-view-id&gt; &lt;navigation-case&gt; &lt;from-outcome&gt;login&lt;/from-outcome&gt; &lt;to-view-id&gt;/pages/home.jsp&lt;/to-view-id&gt; &lt;/navigation-case&gt; &lt;/navigation-rule&gt; &lt;navigation-rule&gt; &lt;from-view-id&gt;/pages/home.jsp&lt;/from-view-id&gt; &lt;navigation-case&gt; &lt;from-outcome&gt;searchForBooks&lt;/from-outcome&gt; &lt;to-view-id&gt;/pages/searchCriteria.jsp&lt;/to-view-id&gt; &lt;/navigation-case&gt; &lt;/navigation-rule&gt; &lt;navigation-rule&gt; &lt;from-view-id&gt;/pages/searchCriteria.jsp&lt;/from-view-id&gt; &lt;navigation-case&gt; &lt;from-outcome&gt;searchForBooks&lt;/from-outcome&gt; &lt;to-view-id&gt;/pages/searchCriteria.jsp&lt;/to-view-id&gt; &lt;/navigation-case&gt; &lt;/navigation-rule&gt; &lt;navigation-rule&gt; &lt;from-view-id&gt;/pages/searchResults.jsp&lt;/from-view-id&gt; &lt;navigation-case&gt; &lt;from-outcome&gt;searchForBooks&lt;/from-outcome&gt; &lt;to-view-id&gt;/pages/searchCriteria.jsp&lt;/to-view-id&gt; &lt;/navigation-case&gt; &lt;/navigation-rule&gt; &lt;navigation-rule&gt; &lt;from-view-id&gt;/pages/searchCriteria.jsp&lt;/from-view-id&gt; &lt;navigation-case&gt; &lt;from-outcome&gt;search&lt;/from-outcome&gt; &lt;to-view-id&gt;/pages/searchResults.jsp&lt;/to-view-id&gt; &lt;/navigation-case&gt; &lt;/navigation-rule&gt; &lt;managed-bean&gt; &lt;managed-bean-name&gt;book&lt;/managed-bean-name&gt; &lt;managed-bean-class&gt;omitted.for.anonymity.beans.Book&lt;/managed-bean-class&gt; &lt;managed-bean-scope&gt;session&lt;/managed-bean-scope&gt; &lt;/managed-bean&gt; &lt;managed-bean&gt; &lt;managed-bean-name&gt;homePage&lt;/managed-bean-name&gt; &lt;managed-bean-class&gt;omitted.for.anonymity.beans.page.HomePage&lt;/managed-bean-class&gt; &lt;managed-bean-scope&gt;session&lt;/managed-bean-scope&gt; &lt;/managed-bean&gt; &lt;managed-bean&gt; &lt;managed-bean-name&gt;searchCriteriaPage&lt;/managed-bean-name&gt; &lt;managed-bean-class&gt;omitted.for.anonymity.beans.page.SearchCriteriaPage&lt;/managed-bean-class&gt; &lt;managed-bean-scope&gt;session&lt;/managed-bean-scope&gt; &lt;/managed-bean&gt; &lt;managed-bean&gt; &lt;managed-bean-name&gt;searchResultsPage&lt;/managed-bean-name&gt; &lt;managed-bean-class&gt;omitted.for.anonymity.beans.page.SearchResultsPage&lt;/managed-bean-class&gt; &lt;managed-bean-scope&gt;request&lt;/managed-bean-scope&gt; &lt;/managed-bean&gt; &lt;/faces-config&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload