title: Load checked checkbox from database in JSF based on boolean
body: <p>I am having dynamic Checkboxes from database and I need them to be checked on page load based on a boolean true or false:</p>
  
  <p>My xhtml:</p>
  
  <pre><code> &lt;h:selectManyCheckbox value="#{report.reports}"&gt;
      &lt;f:selectItems value="#{report.allreports}" /&gt;
   &lt;/h:selectManyCheckbox&gt;
  </code></pre>
  
  <p>My Boolean:</p>
  
  <pre><code> 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 &gt; 0;
      }
  </code></pre>
  
  <p>How can I get My check boxes to be checked if the boolean return true. <code>reportname</code> is the value of the check box and <code>workclass</code> value is in the session.</p>