How do I keep the value of a selected checkbox on a page? in java

0

I am working in java web with jsp and I need to show data from a DB in a table, here I must select with a checkbox field and send the data I select to another jsp, paginate the table with Data Tables, but here when I want to choose items from different pages, just send the items from the page that is being viewed, the other checks are not sent to the jsp.

<form name="" method="post" action="Acta.jsp">
  <table class="table table-striped table-bordered table-hover" class="display" cellspacing="0" width="100%" id="dataTables-example">
    <thead>
      <tr>


        <th>Cantidad</th>
        <th>Tipo</th>
        <th>Marca</th>
        <th>Modelo</th>
        <th>Numero Serie</th>
        <th>Persona Responsable</th>
        <th>Ubicacion</th>
        <th>Fecha Ingreso</th>
        <th>Fuente Financiamiento</th>
        <th>Proyecto</th>
        <th>Numero Factura</th>

        <th>Valor</th>
        <th>Estado</th>
        <th>Fecha Factura</th>
        <th>Agregar</th>

      </tr>
    </thead>




    <tbody>

    <%                  
      LinkedList<BeanMostrarBien> lista= ConsultarBien.consultarBien();
      for(int i=0; i<lista.size(); i++) {

        out.println("<tr>");

        out.println("<td>" + lista.get(i).getCantidad()+    "</td>");
        out.println("<td>" + lista.get(i).getTipoProducto()+    "</td>");
        out.println("<td>" + lista.get(i).getMarca() +  "</td>");
        out.println("<td>" + lista.get(i).getModelo() +     "</td>");
        out.println("<td>" + lista.get(i).getNumeroSerie()+     "</td>");
        out.println("<td>" + lista.get(i).getPersonaResponsable()+  "</td>");
        out.println("<td>" + lista.get(i).getUbicacion()+   "</td>");
        out.println("<td>" + lista.get(i).getFechaIngresoSistema()+  "</td>");
        out.println("<td>" + lista.get(i).getFuenteFinanciamiento() +   "</td>");
        out.println("<td>" + lista.get(i).getProyecto()+    "</td>");
        out.println("<td>" + lista.get(i).getNumeroFactura()+   "</td>");
        out.println("<td>" + lista.get(i).getValor()+   "</td>");
        out.println("<td>" + lista.get(i).getEstado()+  "</td>");
        out.println("<td>" + lista.get(i).getFechaFactura()+    "</td>");

        out.println("<td><center><input  id='agregarBien' type='checkbox' value="+lista.get(i).getId()+" name='agregarBien' ></center></td>");

        out.println("</tr>");            

      }

    %>

    </tbody>

  </table>
  <center><input type="submit" class="btn btn-primary btn-lg" value="Generar Acta"></center>
</form>
</div>

</div>
</div>
</div>
<script>
  $(document).ready(function() {
    $('#dataTables-example').DataTable({
      select: {
        style: 'multi'
      }
    });
  });
</script>
    
asked by Fernando Brito 23.05.2017 в 05:11
source

1 answer

0

If the option to send the data by AJAX fits into your project, the simplest way is to serialize the table:

$('#form-submit').click( function(event) {

  var data = table.$('input').serialize();

  $.post( window.location.href, data).done(function(response){

    //código de éxito

  }).fail(function(){

    //código de error

  });

  return false;

});
    
answered by 23.05.2017 / 10:51
source