【问题标题】:jsf 2.0 how to display data from joined tables?jsf 2.0 如何显示连接表中的数据?
【发布时间】:2012-10-23 08:39:18
【问题描述】:

如何在 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页面上显示

【问题讨论】:

    标签: java jsf xhtml


    【解决方案1】:

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

    【讨论】:

    • 你必须创建的类中的对象;您必须为要在 xhtml 页面中显示的那些字段提供 getter。
    猜你喜欢
    • 2011-08-27
    • 1970-01-01
    • 2023-03-28
    • 1970-01-01
    • 2010-09-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-21
    相关资源
    最近更新 更多