jsf 2.0如何显示连接表中的数据?

时间:2012-10-23 08:39:19

标签: java jsf xhtml

如何在jsf 2.0中显示来自两个连接表的数据?

我有托管bean目录(代表我的数据库中的表):

public class Catalog implements Serializable{



//gettters and setters and atrributes }

我有另一个托管bean(代表我数据库中的另一个表):

public class Profit implements Serializable{


//gettters and setters and attributes}

我有一个返回查询的方法,该查询将这两列(来自数据库)与Catalog id属性连接起来。

我不知道为此方法提供什么返回值以及如何在jsf xhtml页面中显示连接数据...

这是我的方法:

   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
         }

要设置的返回值以及如何在xhtml页面上显示

1 个答案:

答案 0 :(得分:1)

创建一个新的类,它包含Catalog和Profit,或者只包含JOIN中使用的Catalog和Profit中的那些字段。