Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The fields must be likeThis instead of LikeThis. Just change your JSF code to</p> <pre class="lang-html prettyprint-override"><code>&lt;h:dataTable value="#{pretechDataTableBean.user}" var="user"&gt; &lt;h:column&gt; &lt;f:facet name="header"&gt;Name&lt;/f:facet&gt; #{user.fName} &lt;/h:column&gt; &lt;h:column&gt; &lt;f:facet name="header"&gt;Email&lt;/f:facet&gt; #{user.email} &lt;/h:column&gt; &lt;h:column&gt; &lt;f:facet name="header"&gt;Password&lt;/f:facet&gt; #{user.pwd} &lt;/h:column&gt; &lt;/h:dataTable&gt; </code></pre> <p>And update the field names in your <code>User</code> class to follow the proper Java Bean naming convention.</p> <pre><code>public class users implements java.io.Serializable { private long userId; private String fName; private String lName; private long userTypeId; private String userName; private String email; private String pwd; private String note; private boolean isActive; //constructor, getters and setters } </code></pre> <p>Apart from this, there are other bugs in your current design:</p> <ul> <li>You <strong>must not</strong> have business logic in the getters of your managed bean, instead take advantage of the <code>@PostConstruct</code> method to initialize the necessary data to be used.</li> <li>Since this bean looks that should stay alive while the user stays in the same view, it will be better to decorate it as <code>@ViewScoped</code> instead of <code>@RequestScoped</code>.</li> <li>Use proper names for your classes and fields. For example, if you have a <code>List&lt;Something&gt;</code> field, name your variable <code>somethingList</code> or similar in order that the code is self-explanatory.</li> </ul> <p>From these, you can change your managed bean to:</p> <pre><code>@ManagedBean @ViewScoped public class PretechDataTableBean { private List&lt;users&gt; userList; public PretechDataTableBean() { } @PostConstruct public void init() { Session session = HibernateUtil.getSessionFactory().openSession(); Transaction transaction = null; List&lt;users&gt; users =null; try { transaction = session.beginTransaction(); users = session.createQuery("from users").list(); } catch(Exception e) { e.printStackTrace(); } finally{ session.close(); } return users; } public List&lt;users&gt; getUserList() { return this.user; } } </code></pre> <p>Since the field changed its name in the managed bean, you should edit it accordingly in the respective view:</p> <pre class="lang-html prettyprint-override"><code>&lt;h:dataTable value="#{pretechDataTableBean.userList}" var="user"&gt; </code></pre> <p>Related info:</p> <ul> <li><a href="https://stackoverflow.com/q/2090033/1065197">Why JSF calls getters multiple times</a></li> <li><a href="http://balusc.blogspot.com/2011/09/communication-in-jsf-20.html#ManagedBeanScopes" rel="nofollow noreferrer">Communication in JSF 2: Managed bean scopes</a></li> <li><a href="http://download.oracle.com/otn-pub/jcp/7224-javabeans-1.01-fr-spec-oth-JSpec/beans.101.pdf" rel="nofollow noreferrer">JavaBeans API Specification </a>, more specifically, Section 7: Properties.</li> </ul>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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