Skip to content

Instantly share code, notes, and snippets.

@KeyCuevasMelgarejo
Last active May 18, 2022 15:50
Show Gist options
  • Save KeyCuevasMelgarejo/50dd76e1c4c96c677822f8bef9d42e49 to your computer and use it in GitHub Desktop.
Save KeyCuevasMelgarejo/50dd76e1c4c96c677822f8bef9d42e49 to your computer and use it in GitHub Desktop.
Spring | Thymeaf | th:each ~ th:if

Listar items segun su disponibilidad | Ejemplo

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<head th:replace = "layout/plantilla :: head"></head>

<body class="">
    <div class="wrapper">
        <!--  Sidebar -->
        <div th:replace = "layout/plantilla :: sidebar"></div>

        <div class="main-panel">
        <!-- Navbar -->
        <nav th:replace = "layout/plantilla :: navbar"></nav>
        <!-- End Navbar -->

        <!-- Inicio-->
        <div class="content">
            <div class="row">
              <div class="col-md-8">
                <div th:replace = "layout/plantilla :: successMessage"></div>
                <div th:replace = "layout/plantilla :: errorMessage"></div>
                <div th:replace = "layout/plantilla :: auditarMessage"></div>

                <div class="card card-plain">
                  <div class="card-header text-center">
                    <h5 class="title">Lista de partituras incluidas en la cancion</h5>
                  </div>
                  <div class="card-body text-center">
                    <div th:if="${partituras.empty==true} or ${partituras.?[estado=='ACTIVO'].isEmpty()}">
                        Aún no hay registros
                    </div>
                    <table class="table" th:unless="${partituras.empty==true} or ${partituras.?[estado=='ACTIVO'].isEmpty()}">
                      <thead class=" text-primary">
                        <tr>
                          <th class="text-center">Id</th>
                          <th class="text-center">Armazon</th>
                          <th class="text-center">Tempo</th>
                          <th class="text-center text-muted">Opciones</th>
                        </tr>
                      </thead>
                      <tbody>
                        <tr th:each="partitura:${partituras}" th:if="${partitura.estado=='ACTIVO'}"><!--El primero es el nombre del pipe, el segundo es el que esta creado en el componente-->
                          <th class="text-center" scope="row" th:text="${partitura.id}" ></th>
                          <td class="text-center" th:text="${partitura.armazon}"></td>
                          <td class="text-center" th:text="${partitura.tempo}"></td>
                          <td class="td-actions text-center">
                              <a th:href="@{'/partitura/editor/' + ${partitura.id}}" class="badge badge-info">
                              <i class="tim-icons icon-pencil"></i>
                              </a>
                              <a th:href="@{'/partitura/desactivar/' + ${partitura.id}}" class="badge badge-primary">
                              <i class="tim-icons icon-simple-remove"></i>
                              </a>
                          </td>
                        </tr>
                      </tbody>
                    </table>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
    </div>
   </body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment