Capture data that are in foreach in spring

3

hello I have a problem is that I do not know how to get the selected data with checkbox outside the foreach in the part that says class="text-left" href="< value=" eliminar_dependencia.htm?id="/>" .. should perform the function

<div class="container-fluid">
  <div class="widget-title"> <span class="icon"><i class="icon-envelope"></i></span>
    <h5>Administración Dependencias</h5>
    <a class="text-left" href="<c:url value=" eliminar_dependencia.htm?id="/>"><span class="icon"><i class="icon-trash"></i></span></a>
    <a href="<c:url value=" nueva_dependencia.htm "/>"><span class="icon"><i class="icon-plus"></i></span></a>
  </div>

  <c:forEach items="${depende}" var="dato">
    <tr>
      <td><input type="checkbox" name="Selec" value="ON" /></td>
      <td>
        <c:out value="${dato.idDependencias}" />
      </td>
      <td>
        <c:out value="${dato.nomDependencia}" />
      </td>
      <td <a href="<c:url value=" eliminar_dependencia.htm?id=${dato.idDependencias} "/>">Eliminar</a>
      </td>
    </tr>
  </c:forEach>
    
asked by Kevin Castaño 28.04.2017 в 16:18
source

1 answer

0

One option would be to add an attribute isSelected to dato

public class Dato{
   private boolean isDependencia;
   private String nomDependencia;
   private boolean isSelected;

   //getters and setters

}

And that said attribute is binded to the checkbox

      <td><input type="checkbox" name="Selec" value="${dato.isSelected}" /></td>

Then, the backend that captures the request of eliminar_dependencia.htm should go through your list that you called depende and recover the data whose value for isSelected is true

I hope I have interpreted the query well and that it helps you.

    
answered by 01.05.2017 / 22:18
source