I have a DAO that returns some informations of my database. I want show thats informations in a table but doesn't work. The informations not displayed.
I'm trying this.
//DAO
public class CustomerDAO {
private Connection con = connection.getConnection();
public List<Customer> getCustomer(){
List<Customer> list = new ArrayList<Customer>();
PreparedStatement stm = this.con.prepareStatement("SELECT * FROM customer");
ResultSet rs = stm.executeQuery();
while(rs.next()){
Customer c = new Customer();
c.setName(rs.getString("name"));
list.add(c);
}
return list;
}
}
// customer view
public class CustomerView extends CustomComponents{
private Table table;
private List<Customer> list;
public CustomerView(){
table = new Table();
table.setSizeFull();
tabela.addContainerProperty("Customer", String.class, null);
getCustomer();
}
/** populate table */
private void getCustomer(){
list = new CustomerDAO().getCustomer();
if(!list.isEmpty()){
for(Customer c : list){
table.addItem(new Object[]{c.getName()}, 1);
}
}
}
}
Any idea ?