From e44552ea4c45c98ca6b7e3918748b13a9200b83c Mon Sep 17 00:00:00 2001
From: Thibault Duchateau <thibault.duchateau@gmail.com>
Date: Sun, 24 Feb 2013 20:36:09 +0100
Subject: [PATCH] Added Dandelion-Datatables

New dependencies added
Old tables replaced by Datatables using Dandelion-Datatables
---
 pom.xml                                       | 17 +++++-
 .../webapp/WEB-INF/jsp/owners/ownersList.jsp  | 55 ++++++++-----------
 src/main/webapp/WEB-INF/jsp/vets/vetList.jsp  | 35 +++++-------
 3 files changed, 52 insertions(+), 55 deletions(-)

diff --git a/pom.xml b/pom.xml
index 186d2746..03307a23 100644
--- a/pom.xml
+++ b/pom.xml
@@ -47,7 +47,9 @@
         <webjars-bootstrap.version>2.3.0</webjars-bootstrap.version>
         <webjars-jquery-ui.version>1.9.2</webjars-jquery-ui.version>
         <webjars-jquery.version>1.9.0</webjars-jquery.version>
-
+        <dandelion.datatables.version>0.8.5</dandelion.datatables.version>
+        <dandelion.datatables.export.itext.version>0.1.5</dandelion.datatables.export.itext.version>
+      
         <maven-assembly-plugin.version>2.4</maven-assembly-plugin.version>
         <maven-clean-plugin.version>2.5</maven-clean-plugin.version>
         <maven-compiler-plugin.version>3.0</maven-compiler-plugin.version>
@@ -234,7 +236,18 @@
             <groupId>org.aspectj</groupId>
             <artifactId>aspectjweaver</artifactId>
         </dependency>
-    </dependencies>
+        <!-- Dandelion -->
+        <dependency>
+            <groupId>com.github.dandelion</groupId>
+            <artifactId>datatables-jsp</artifactId>
+            <version>${dandelion.datatables.version}</version>
+         </dependency>
+         <dependency>
+            <groupId>com.github.dandelion</groupId>
+            <artifactId>datatables-export-itext</artifactId>
+            <version>${dandelion.datatables.export.itext.version}</version>
+         </dependency>
+       </dependencies>
 
     <!-- all Maven plugin versions are mentioned in order to guarantee the build reproducibility in the long term -->
     <build>
diff --git a/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp b/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp
index 03f78582..ac2aafdb 100644
--- a/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp
+++ b/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp
@@ -2,7 +2,7 @@
 <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
 <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
-
+<%@ taglib prefix="datatables" uri="http://github.com/dandelion/datatables" %>
 
 <html lang="en">
 
@@ -12,36 +12,29 @@
 <div class="container">
     <jsp:include page="../fragments/bodyHeader.jsp"/>
     <h2>Owners</h2>
-
-    <table class="table table-striped">
-        <thead>
-        <tr>
-            <th style="width: 150px;">Name</th>
-            <th style="width: 200px;">Address</th>
-            <th>City</th>
-            <th>Telephone</th>
-            <th style="width: 100px;">Pets</th>
-        </tr>
-        </thead>
-        <c:forEach var="owner" items="${selections}">
-            <tr>
-                <td>
-                    <spring:url value="owners/{ownerId}.html" var="ownerUrl">
-                        <spring:param name="ownerId" value="${owner.id}"/>
-                    </spring:url>
-                    <a href="${fn:escapeXml(ownerUrl)}"><c:out value="${owner.firstName} ${owner.lastName}"/></a>
-                </td>
-                <td><c:out value="${owner.address}"/></td>
-                <td><c:out value="${owner.city}"/></td>
-                <td><c:out value="${owner.telephone}"/></td>
-                <td>
-                    <c:forEach var="pet" items="${owner.pets}">
-                        <c:out value="${pet.name}"/>
-                    </c:forEach>
-                </td>
-            </tr>
-        </c:forEach>
-    </table>
+    
+    <datatables:table id="owners" data="${selections}" cdn="true" row="owner" theme="bootstrap2" 
+                      cssClass="table table-striped" paginate="false" info="false" export="pdf">
+        <datatables:column title="Name" cssStyle="width: 150px;" display="html">
+            <spring:url value="owners/{ownerId}.html" var="ownerUrl">
+                <spring:param name="ownerId" value="${owner.id}"/>
+            </spring:url>
+            <a href="${fn:escapeXml(ownerUrl)}"><c:out value="${owner.firstName} ${owner.lastName}"/></a>
+        </datatables:column>
+        <datatables:column title="Name" display="pdf">
+            <c:out value="${owner.firstName} ${owner.lastName}"/>
+        </datatables:column>
+        <datatables:column title="Address" property="address" cssStyle="width: 200px;"/>
+        <datatables:column title="City" property="city"/>
+        <datatables:column title="Telephone" property="telephone"/>
+        <datatables:column title="Pets" cssStyle="width: 100px;">
+            <c:forEach var="pet" items="${owner.pets}">
+                <c:out value="${pet.name}"/>
+            </c:forEach>
+        </datatables:column>
+        <datatables:export type="pdf" cssClass="btn btn-small" />
+    </datatables:table>
+    
     <jsp:include page="../fragments/footer.jsp"/>
 
 </div>
diff --git a/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp b/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp
index 4adaa14d..93ad827d 100644
--- a/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp
+++ b/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp
@@ -1,7 +1,7 @@
 <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
 <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
-
+<%@ taglib prefix="datatables" uri="http://github.com/dandelion/datatables" %>
 
 <html lang="en">
 
@@ -14,27 +14,18 @@
 
     <h2>Veterinarians</h2>
 
-    <table class="table table-stripped" style="width:600px;">
-        <thead>
-        <tr>
-            <th>Name</th>
-            <th>Specialties</th>
-        </tr>
-        </thead>
-        <tbody>
-        <c:forEach var="vet" items="${vets.vetList}">
-            <tr>
-                <td><c:out value="${vet.firstName} ${vet.lastName}"/></td>
-                <td>
-                    <c:forEach var="specialty" items="${vet.specialties}">
-                        <c:out value="${specialty.name}"/>
-                    </c:forEach>
-                    <c:if test="${vet.nrOfSpecialties == 0}">none</c:if>
-                </td>
-            </tr>
-        </c:forEach>
-        </tbody>
-    </table>
+    <datatables:table id="vets" data="${vets.vetList}" cdn="true" row="vet" theme="bootstrap2" cssClass="table table-striped" paginate="false" info="false">
+        <datatables:column title="Name">
+            <c:out value="${vet.firstName} ${vet.lastName}"></c:out>
+        </datatables:column>
+        <datatables:column title="Specialties">
+            <c:forEach var="specialty" items="${vet.specialties}">
+                <c:out value="${specialty.name}"/>
+            </c:forEach>
+            <c:if test="${vet.nrOfSpecialties == 0}">none</c:if>
+        </datatables:column>
+    </datatables:table>
+    
     <table class="table-buttons">
         <tr>
             <td>
-- 
GitLab