0

データベースから動的なチェックボックスを持っています。ブール値の true または false に基づいて、ページの読み込み時にそれらをチェックする必要があります。

私のxhtml:

 <h:selectManyCheckbox value="#{report.reports}">
    <f:selectItems value="#{report.allreports}" />
 </h:selectManyCheckbox>

私のブール値:

 public boolean checkedBox(String workclass, String reportname) {
        Connection conn;
        int count = 0;
        try {
            conn = db.getDbConnection();
            String sql = "select count(*)NUM from rep_access where user_work_class  = ? and rep_name = ?";
            PreparedStatement ps = conn.prepareStatement(sql);
            ps.setString(1, workclass);
            ps.setString(2, reportname);
            ResultSet rs = ps.executeQuery();
            while (rs.next()) {
                count = rs.getInt(1);
            }
            DBConnection.closeConn(conn);
        } catch (SQLException asd) {
            System.out.println(asd.getMessage());
        } catch (IOException asd) {
            System.out.println(asd.getMessage());
        }
        return count > 0;
    }

ブール値がtrueを返す場合、チェックボックスをチェックするにはどうすればよいですか。reportnameはチェック ボックスの値で、workclass値はセッション内にあります。

4

0 に答える 0