How can i display data from two joined tables in jsf 2.0?
I have managed bean Catalog(represents table in my database):
public class Catalog implements Serializable{
//gettters and setters and atrributes }
and i have another managed bean(represents another table in my database):
public class Profit implements Serializable{
//gettters and setters and attributes}
I have a method that returns query which is joining this two columns(from database) with the Catalog id property.
I have no idea what return value to give to this method and how do display joined data in jsf xhtml page…
This is my method:
public <what return value to put> method throws Exception {
connect(); //to databse
String query="SELECT....";
//this query is prefectly good, i tested it in sql server, it does the job
Statement st=connection.createStatement();
ResultSet rs=st.executeQuery(upit);
while(rs.next()) {
//setting the values from my databse
}
return <what to return here> //this is the trick part
}
What return value to set and how to display it on xhtml page
Create a new class that wraps up Catalog and Profit, or only those fields from Catalog and Profit used in the JOIN.