Java Question

<table> display values from BEAN method

So i have this table in my xhtml:

<section class="content">
<div class="row">
<div class="col-xs-12">

<div class="box">
<div class="box-header">
<h3 class="box-title">Data Table With Full Features</h3>
</div>
<!-- /.box-header -->
<div class="box-body">
<table id="tbResult" class="table table-bordered table-striped">
<thead>
<tr>
<th>#{msg.Sgc001tbcod}</th>
<th>Browser</th>
</tr>
</thead>

<tfoot>
<tr>
<th>Rendering engine</th>
<th>Browser</th>
</tr>
</tfoot>
</table>
</div>
<!-- /.box-body -->
</div>
<!-- /.box -->
</div>
<!-- /.col -->
</div>
<!-- /.row -->
</section>


And this select on my BEAN:

public void select(int first, int pageSize, String sortField, Object filterValue) throws SQLException, ClassNotFoundException, NamingException {

//System.out.println("entre al metodo SELECT");
Context initContext = new InitialContext();
DataSource ds = (DataSource) initContext.lookup(JNDI);
con = ds.getConnection();
//Reconoce la base de datos de conección para ejecutar el query correspondiente a cada uno
DatabaseMetaData databaseMetaData = con.getMetaData();
productName = databaseMetaData.getDatabaseProductName();//Identifica la base de datos de conección

//Consulta paginada
String query = "SELECT * FROM";
query += "(select query.*, rownum as rn from";
query += "(SELECT A.CODIGO, A.DESCR ";
query += " FROM PRUEBA1 A";
query += " GROUP BY A.CODIGO, A.DESCR";
query += ")query ) " ;
query += " WHERE ROWNUM <="+pageSize;
query += " AND rn > ("+ first +")";
query += " ORDER BY " + sortField.replace("z", "");

pstmt = con.prepareStatement(query);
//System.out.println(query);

r = pstmt.executeQuery();

while (r.next()){
Prueba select = new Prueba();
select.setZcodigo(r.getString(1));
select.setZdesc(r.getString(2));

//Agrega la lista
list.add(select);
}
//Cierra las conecciones
pstmt.close();
con.close();

}


How can i make it so that i can display the values of the Select() method in the table? ive tried a few things with no success, and i wanna use this instead of dataTable to learn something new.

Thanks in advance

Answer

Finally!! after week's of research i found a solution for this:

Code:

 <div class="box">
                        <div class="box-header">
                          <h3 class="box-title">Data Table With Full Features</h3>
                        </div>
                        <!-- /.box-header -->
                        <div class="box-body">
                          <table id="tbResult" class="table table-bordered table-striped" cellspacing="0" width="100%">
                            <thead>
                            <tr>
                              <th>#{msg.Sgc001tbcod}</th>
                              <th>#{msg.Sgc001tbdes}</th>
                            </tr>
                            </thead>
                             <tbody>
                                 <c:forEach items="#{prueba.table}" varStatus="loop">
                                     <tr>
                                        <td><h:outputText value="#{prueba.vltabla[loop.index][0]}" /></td>
                                        <td><h:outputText value="#{prueba.vltabla[loop.index][1]}" /></td>
                                     </tr>        
                                 </c:forEach>
                             </tbody>
                            <tfoot>
                            <tr>
                              <th>#{msg.Sgc001tbcod}</th>
                              <th>#{msg.Sgc001tbdes}</th>
                            </tr>
                            </tfoot>
                          </table>
                        </div>
                        <!-- /.box-body -->
                      </div>

And BEAN:

/**
                 * Leer registros en la tabla
                 * @throws NamingException 
                 * @throws IOException 
                **/ 

                private void select() throws NamingException {  

                    //System.out.println("entre al metodo SELECT");     
                // ESTE SELECT SE ENCARGAR DE LLENAR EL ARREGLO VLTABLA PARA LA ETIQUETA FOREACH //     

                //Consulta paginada             
                String query = "SELECT A.CODIGO, A.DESCR ";
                    query += " FROM PRUEBA1 A";
                    query += " GROUP BY A.CODIGO, A.DESCR";
                    query += " ORDER BY  1";
                //System.out.println(query);

                consulta.selectPntGenerica(query, JNDI);    
                inputnumber = consulta.getRows();
                if(inputnumber>0){
                vltabla = consulta.getArray();

                  } 
               }

call the method select() in the init and works like a charm.