this one is my jsf page in which i have tried a very good to meet the requirement on the properties of java bean object. I have checked all the problem in this website but noon of seem to help. I dont know what is problem with my code
<h:dataTable value="#{contact.getPeopleList()}" var="data">
<h:column>
<f:facet name="header">ID</f:facet>
<h:outputText value="#{data.id}"/>
</h:column>
<h:column>
<f:facet name="header">Name</f:facet>
<h:outputText value="#{persons.name}"/>
</h:column>
<h:column>
<f:facet name="header">Mobile Number</f:facet>
#{persons.mobilenumber}
</h:column>
<h:column>
<f:facet name="header">Phone Number</f:facet>
#{persons.telephone}
</h:column>
<h:column>
<f:facet name="header">Address</f:facet>
#{persons.address}
</h:column>
</h:dataTable>
</h:body>
This one is my Contact CLass in which i have inject Person class to get the properties of Person class
@Named
@RequestScoped
public class Contact {
private Person person;
@PostConstruct
public void init(){
this.person=new Person();
}
public Person getPerson() {
return person;
}
public void setPerson(Person person) {
this.person = person;
}
public String onSubmit(){
ContactDAO doaContact=new ContactDAO();
doaContact.insertContact(person);
return "contactpage";
}
public List<Person> getPeopleList(){
ContactDAO doaContact=new ContactDAO();
List<Person> personList =doaContact.getAll();
return personList;
}
}
package np.com.drose.beans;
import java.util.List;
import np.com.drose.doa.ContactDAO;
public class Person {
private int id;
private String name;
private int mobilenumber;
private int telephone;
private String address;
public Person() {
}
public Person(int id, String name, int mobilenumber, int telephone, String address) {
this.id = id;
this.name = name;
this.mobilenumber = mobilenumber;
this.telephone = telephone;
this.address = address;
}
public Person(String name, int mobilenumber, int telephone, String address) {
this.name = name;
this.mobilenumber = mobilenumber;
this.telephone = telephone;
this.address = address;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getMobilenumber() {
return mobilenumber;
}
public void setMobilenumber(int mobilenumber) {
this.mobilenumber = mobilenumber;
}
public int getTelephone() {
return telephone;
}
public void setTelephone(int telephone) {
this.telephone = telephone;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
}
here i get confused in the Data access object class where i cant seem to find what i did wrong and why my code is not rendering data from database
public List<Person> getAll(){
List<Person> contactList= new LinkedList<>();
String sql="Select * from contact";
try{
conn = DataConnection.getConnetion();
ps=conn.prepareStatement(sql);
rs=ps.executeQuery();
while(rs.next()){
Person person=new Person(rs.getInt("id"),rs.getString("name"),rs.getInt("mobilenumber"),rs.getInt("telephone"),rs.getString("address"));
contactList.add(person);
}
}catch(Exception EX){
EX.printStackTrace();
}
return contactList;
}