problem with complex bean
Hi,
i'm newbie and i've got big problem
i have a database tables for a school, in one table there are the students, in the second courses and in third the marks
when i choose a particular student i want to see the table with all the courses and list of his marks in one row - something like that:
person : Peter Cichon
math 5,4,5,3 and button "add mark"
physics 5,6,5,4 and button "add mark"
and so on
i do not want to see it in this manner:
person : Peter Cichon
math 5
math 4
math5
math 3
physics 5
.....
is it possible to create a backing bean that will return the ..jstl.Result and use it in h:DataTable
thanks in advance and sorry for my english
peterc
[775 byte] By [
pietruchaa] at [2007-11-26 15:57:29]

# 1
you should write backing bean method such that, it returns you the data in sequence you want.
For ex, you can write a method such that it returns you subject, math1,math2,.... so on...
& finally you retrieve each column object in <h:column> of dataTable.....
Hope I understood properly.....
# 4
thanks, but i dont know how - i'm beginner in java
in the bean i use something like this
public class MarksBean {........
.....
public Result getMarks() throws SQLException, NamingException {
try {
Context ctx = new InitialContext();
if (ctx == null) throw new NamingException("No initial context");
DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/school_");
if (ds == null) throw new NamingException("No data source");
Connection conn = ds.getConnection();
if (conn == null) throw new SQLException("No connection");
Statement sql = conn.createStatement();
ResultSet result = sql.executeQuery("select p.person_id, s.subject_id, m.mark_id from marks m , subject s, person p where person_id=1 and p.person_id - m.person_id and s.subject_id = m.subject_id");
return ResultSupport.toResult(result);
}
finally {
conn.close();
}
but (of course) this is not what i want - is it posible to change this in simple way to obtain data in the right way
my second question is : is it posible to make a Result not from MySQL Table but from MySQL View
once again sorry for my English
peterc