0

I'm trying to add some mysql table columns to JSF table. And I'm getting error:

/index.xhtml: The class 'logon.User' does not have the property 'description'. Please help

User.java

package logon;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name="users")
public class User {

    private int id;
    public String name = null;
    public String surname = null;
    public String username = null;
    public String description = null;
    public String email = null;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public int getId(){
        return id;
    }
    public void setId(int id){
        this.id = id;
    }

    @Column(name = "Name")
    public String getName(){
        return name;
    }

    public void setName(String Name){
        this.name = Name;
    }

    @Column(name = "Surname")
    public String getSurname(){
        return surname;
    }

    public void setSurname(String Surname){
        this.surname = Surname;
    }

    @Column(name = "Username")
    public String getUsername(){
        return username;
    }
    public void setUsername(String Username){
        this.username = Username;
    }
    @Column(name = "Description")
    public String getDescription(){
        return description;
    }

    public void setDescription(String Description){
        this.description = Description;
    }

}

LogonTest.java

package logon;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;


import javax.annotation.PostConstruct;
import javax.enterprise.context.SessionScoped;
import javax.faces.bean.ViewScoped;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceUnit;
import javax.persistence.Query;


@ViewScoped
@SessionScoped
@javax.faces.bean.ManagedBean(name = "logonTest")
public class LogonTest implements Serializable {
    @PersistenceUnit(unitName = "Webbeans_RESOURCE_LOCAL")
    private EntityManagerFactory emf;

    public List<User> getUserList() {
        return userList;
    }

    public void setUserList(List<User> userList) {
        this.userList = userList;
    }

    public List<User> userList = new ArrayList();


    @PostConstruct
    public void init() {
        EntityManager em = emf.createEntityManager();
        // Read the existing entries and write to console
        Query q = em.createQuery("SELECT u FROM User u");
        userList = q.getResultList();
        System.out.println("Size: " + userList.size());
    }

    public LogonTest() {

    }

}

index.xhtml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
        >
<h:head>
    <title>index.xhtml</title>
</h:head>

<h:body>

    <h1>JSF 2.0 View Data From The Database Table Example</h1>

    <h:dataTable value="#{logonTest.userList}" var="u" border="1">


        <h:column>
            <f:facet name="header">
                ID
            </f:facet>
            #{u.id}
        </h:column>

        <h:column>
            <f:facet name="header">
                Name
            </f:facet>
            #{u.username}
        </h:column>

        <h:column>
            <f:facet name="header">
                Surname
            </f:facet>
            #{u.surname}
        </h:column>

        <h:column>
            <f:facet name="header">
                Name
            </f:facet>
            #{u.name}
        </h:column>

        <h:column>
            <f:facet name="header">
                Description
            </f:facet>
            #{u.description}
        </h:column>

    </h:dataTable>

</h:body>

</html>
2
Contributors
1
Reply
10
Views
3 Years
Discussion Span
Last Post by stultuske
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.