G
gbattine
HI guys,
i'm a new user of JSF and now i'm descovering great possibilities
offered by datatable.
I read the article on
http://balusc.xs4all.nl/srv/dev-j2p-dat.html#RetrieveAndStoreData,
Not everythings are for me clear...
I've to show in a datatable a mysql table
utenti(firstName,lastName,city)
which its relative values..
i've developed a User class with the tree values as private variables
and getter and setter methods...
For this class i've developed a method called userList() that should
return a List of all the users presents in the table,ordereb by name.
Can someone say me what are the successive steps?Can you help me with a
bit theory about wrapper class?
Can you help me step by step because i don't understand internet
articles and forum discussions?
public List userList() throws Exception {
Context ctx = new InitialContext();
if (ctx == null) {
throw new Exception("Boom - No Context");
}
Context envCtx = (Context) ctx.lookup("java:comp/env");
DataSource ds = (DataSource) ctx.lookup("java:comp/env/MysqlJNDI");
// "java:comp/env/jdbc/nomedb"
Connection conn = ds.getConnection();
Statement stm = conn.createStatement();
ResultSet rst = stm.executeQuery("select * from utenti order by
username");
List users = new ArrayList();
while (rst.next()){
users.add(rst.getString("firstname"));
users.add(rst.getString("lastname"));
users.add(rst.getString("city"));
}
return users;
}
Please help me....
i'm a new user of JSF and now i'm descovering great possibilities
offered by datatable.
I read the article on
http://balusc.xs4all.nl/srv/dev-j2p-dat.html#RetrieveAndStoreData,
Not everythings are for me clear...
I've to show in a datatable a mysql table
utenti(firstName,lastName,city)
which its relative values..
i've developed a User class with the tree values as private variables
and getter and setter methods...
For this class i've developed a method called userList() that should
return a List of all the users presents in the table,ordereb by name.
Can someone say me what are the successive steps?Can you help me with a
bit theory about wrapper class?
Can you help me step by step because i don't understand internet
articles and forum discussions?
public List userList() throws Exception {
Context ctx = new InitialContext();
if (ctx == null) {
throw new Exception("Boom - No Context");
}
Context envCtx = (Context) ctx.lookup("java:comp/env");
DataSource ds = (DataSource) ctx.lookup("java:comp/env/MysqlJNDI");
// "java:comp/env/jdbc/nomedb"
Connection conn = ds.getConnection();
Statement stm = conn.createStatement();
ResultSet rst = stm.executeQuery("select * from utenti order by
username");
List users = new ArrayList();
while (rst.next()){
users.add(rst.getString("firstname"));
users.add(rst.getString("lastname"));
users.add(rst.getString("city"));
}
return users;
}
Please help me....