petclinic-uncached
Changes
src/main/webapp/WEB-INF/jsp/exception.jsp 34(+7 -27)
src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp 187(+85 -102)
src/main/webapp/WEB-INF/jsp/vets/vetList.jsp 72(+28 -44)
src/main/webapp/WEB-INF/jsp/welcome.jsp 34(+8 -26)
src/main/webapp/WEB-INF/tags/layout.tag 27(+27 -0)
src/main/webapp/WEB-INF/tags/menu.tag 68(+26 -42)
src/main/webapp/WEB-INF/tags/menuItem.tag 13(+13 -0)
Details
src/main/webapp/WEB-INF/jsp/exception.jsp 34(+7 -27)
diff --git a/src/main/webapp/WEB-INF/jsp/exception.jsp b/src/main/webapp/WEB-INF/jsp/exception.jsp
index a4fde6c..d030d59 100644
--- a/src/main/webapp/WEB-INF/jsp/exception.jsp
+++ b/src/main/webapp/WEB-INF/jsp/exception.jsp
@@ -1,34 +1,14 @@
-<!DOCTYPE html>
-
-<%@ page session="false" %>
+<%@ page session="false" trimDirectiveWhitespaces="true" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
-<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
-<html lang="en">
-<jsp:include page="fragments/htmlHeader.jsp"/>
-
-<body>
-<petclinic:bodyHeader menuName="error"/>
-<div class="container-fluid">
- <div class="container xd-container">
-
- <spring:url value="/resources/images/pets.png" var="petsImage"/>
- <img src="${petsImage}"/>
+<petclinic:layout pageName="error">
- <h2>Something happened...</h2>
+ <spring:url value="/resources/images/pets.png" var="petsImage"/>
+ <img src="${petsImage}"/>
- <p>${exception.message}</p>
+ <h2>Something happened...</h2>
- <!-- Exception: ${exception.message}.
- <c:forEach items="${exception.stackTrace}" var="stackTrace">
- ${stackTrace}
- </c:forEach>
- -->
- <petclinic:pivotal/>
- </div>
-</div>
-<jsp:include page="fragments/footer.jsp"/>
-</body>
+ <p>${exception.message}</p>
-</html>
+</petclinic:layout>
diff --git a/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp b/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp
index 77826de..d0aa9d5 100644
--- a/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp
+++ b/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp
@@ -1,5 +1,3 @@
-<!DOCTYPE html>
-
<%@ page session="false" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
@@ -8,43 +6,29 @@
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
-
-<html lang="en">
-
-<jsp:include page="../fragments/htmlHeader.jsp"/>
-
-<body>
-<petclinic:bodyHeader menuName="owners"/>
-<div class="container-fluid">
- <div class="container xd-container">
- <h2>
- <c:if test="${owner['new']}">New </c:if> Owner
- </h2>
- <form:form modelAttribute="owner" class="form-horizontal" id="add-owner-form">
- <div class="form-group has-feedback">
- <petclinic:inputField label="First Name" name="firstName"/>
- <petclinic:inputField label="Last Name" name="lastName"/>
- <petclinic:inputField label="Address" name="address"/>
- <petclinic:inputField label="City" name="city"/>
- <petclinic:inputField label="Telephone" name="telephone"/>
- </div>
- <div class="form-group">
- <div class="col-sm-offset-2 col-sm-10">
- <c:choose>
- <c:when test="${owner['new']}">
- <button class="btn btn-default" type="submit">Add Owner</button>
- </c:when>
- <c:otherwise>
- <button class="btn btn-default" type="submit">Update Owner</button>
- </c:otherwise>
- </c:choose>
- </div>
+<petclinic:layout pageName="owners">
+ <h2>
+ <c:if test="${owner['new']}">New </c:if> Owner
+ </h2>
+ <form:form modelAttribute="owner" class="form-horizontal" id="add-owner-form">
+ <div class="form-group has-feedback">
+ <petclinic:inputField label="First Name" name="firstName"/>
+ <petclinic:inputField label="Last Name" name="lastName"/>
+ <petclinic:inputField label="Address" name="address"/>
+ <petclinic:inputField label="City" name="city"/>
+ <petclinic:inputField label="Telephone" name="telephone"/>
+ </div>
+ <div class="form-group">
+ <div class="col-sm-offset-2 col-sm-10">
+ <c:choose>
+ <c:when test="${owner['new']}">
+ <button class="btn btn-default" type="submit">Add Owner</button>
+ </c:when>
+ <c:otherwise>
+ <button class="btn btn-default" type="submit">Update Owner</button>
+ </c:otherwise>
+ </c:choose>
</div>
- </form:form>
- <petclinic:pivotal/>
- </div>
-</div>
-<jsp:include page="../fragments/footer.jsp"/>
-</body>
-
-</html>
+ </div>
+ </form:form>
+</petclinic:layout>
diff --git a/src/main/webapp/WEB-INF/jsp/owners/findOwners.jsp b/src/main/webapp/WEB-INF/jsp/owners/findOwners.jsp
index e9f9b90..13b9a3d 100644
--- a/src/main/webapp/WEB-INF/jsp/owners/findOwners.jsp
+++ b/src/main/webapp/WEB-INF/jsp/owners/findOwners.jsp
@@ -1,5 +1,3 @@
-<!DOCTYPE html>
-
<%@ page session="false" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
@@ -7,45 +5,30 @@
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
-<html lang="en">
-
-<jsp:include page="../fragments/htmlHeader.jsp"/>
+<petclinic:layout pageName="owners">
-<body>
-<petclinic:bodyHeader menuName="owners"/>
-<div class="container-fluid">
- <div class="container xd-container">
+ <h2>Find Owners</h2>
- <h2>Find Owners</h2>
-
- <spring:url value="/owners.html" var="formUrl"/>
- <form:form modelAttribute="owner" action="${fn:escapeXml(formUrl)}" method="get" class="form-horizontal"
- id="search-owner-form">
- <div class="form-group">
- <div class="control-group" id="lastName">
- <label class="col-sm-2 control-label">Last name </label>
- <div class="col-sm-10">
- <form:input class="form-control" path="lastName" size="30" maxlength="80"/>
- <span class="help-inline"><form:errors path="*"/></span>
- </div>
+ <spring:url value="/owners.html" var="formUrl"/>
+ <form:form modelAttribute="owner" action="${fn:escapeXml(formUrl)}" method="get" class="form-horizontal"
+ id="search-owner-form">
+ <div class="form-group">
+ <div class="control-group" id="lastName">
+ <label class="col-sm-2 control-label">Last name </label>
+ <div class="col-sm-10">
+ <form:input class="form-control" path="lastName" size="30" maxlength="80"/>
+ <span class="help-inline"><form:errors path="*"/></span>
</div>
</div>
- <div class="form-group">
- <div class="col-sm-offset-2 col-sm-10">
- <button type="submit" class="btn btn-default">Find Owner</button>
- </div>
+ </div>
+ <div class="form-group">
+ <div class="col-sm-offset-2 col-sm-10">
+ <button type="submit" class="btn btn-default">Find Owner</button>
</div>
+ </div>
- </form:form>
-
- <br/>
- <a class="btn btn-default" href='<spring:url value="/owners/new" htmlEscape="true"/>'>Add Owner</a>
-
- <petclinic:pivotal/>
- </div>
-</div>
-
-<jsp:include page="../fragments/footer.jsp"/>
-</body>
+ </form:form>
-</html>
+ <br/>
+ <a class="btn btn-default" href='<spring:url value="/owners/new" htmlEscape="true"/>'>Add Owner</a>
+</petclinic:layout>
src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp 187(+85 -102)
diff --git a/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp b/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp
index 54eade3..3cfbdde 100644
--- a/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp
+++ b/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp
@@ -1,5 +1,3 @@
-<!DOCTYPE html>
-
<%@ page session="false" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
@@ -8,109 +6,94 @@
<%@ taglib prefix="joda" uri="http://www.joda.org/joda/time/tags" %>
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
-<html lang="en">
-
-<jsp:include page="../fragments/htmlHeader.jsp"/>
-
-<body>
-<petclinic:bodyHeader menuName="owners"/>
-<div class="container-fluid">
- <div class="container xd-container">
+<petclinic:layout pageName="owners">
+
+ <h2>Owner Information</h2>
+
+
+ <table class="table table-striped">
+ <tr>
+ <th>Name</th>
+ <td><b><c:out value="${owner.firstName} ${owner.lastName}"/></b></td>
+ </tr>
+ <tr>
+ <th>Address</th>
+ <td><c:out value="${owner.address}"/></td>
+ </tr>
+ <tr>
+ <th>City</th>
+ <td><c:out value="${owner.city}"/></td>
+ </tr>
+ <tr>
+ <th>Telephone</th>
+ <td><c:out value="${owner.telephone}"/></td>
+ </tr>
+ </table>
+
+ <spring:url value="{ownerId}/edit.html" var="editUrl">
+ <spring:param name="ownerId" value="${owner.id}"/>
+ </spring:url>
+ <a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Edit Owner</a>
+
+ <spring:url value="{ownerId}/pets/new.html" var="addUrl">
+ <spring:param name="ownerId" value="${owner.id}"/>
+ </spring:url>
+ <a href="${fn:escapeXml(addUrl)}" class="btn btn-default">Add New Pet</a>
+
+ <br/>
+ <br/>
+ <br/>
+ <h2>Pets and Visits</h2>
+
+ <table class="table table-striped">
+ <c:forEach var="pet" items="${owner.pets}">
- <h2>Owner Information</h2>
-
-
- <table class="table table-striped">
- <tr>
- <th>Name</th>
- <td><b><c:out value="${owner.firstName} ${owner.lastName}"/></b></td>
- </tr>
- <tr>
- <th>Address</th>
- <td><c:out value="${owner.address}"/></td>
- </tr>
<tr>
- <th>City</th>
- <td><c:out value="${owner.city}"/></td>
- </tr>
- <tr>
- <th>Telephone</th>
- <td><c:out value="${owner.telephone}"/></td>
- </tr>
- </table>
-
- <spring:url value="{ownerId}/edit.html" var="editUrl">
- <spring:param name="ownerId" value="${owner.id}"/>
- </spring:url>
- <a href="${fn:escapeXml(editUrl)}" class="btn btn-default">Edit Owner</a>
-
- <spring:url value="{ownerId}/pets/new.html" var="addUrl">
- <spring:param name="ownerId" value="${owner.id}"/>
- </spring:url>
- <a href="${fn:escapeXml(addUrl)}" class="btn btn-default">Add New Pet</a>
-
- <br/>
- <br/>
- <br/>
- <h2>Pets and Visits</h2>
-
- <table class="table table-striped">
- <c:forEach var="pet" items="${owner.pets}">
-
- <tr>
- <td valign="top">
- <dl class="dl-horizontal">
- <dt>Name</dt>
- <dd><c:out value="${pet.name}"/></dd>
- <dt>Birth Date</dt>
- <dd><joda:format value="${pet.birthDate}" pattern="yyyy-MM-dd"/></dd>
- <dt>Type</dt>
- <dd><c:out value="${pet.type.name}"/></dd>
- </dl>
- </td>
- <td valign="top">
- <table class="table-condensed">
- <thead>
+ <td valign="top">
+ <dl class="dl-horizontal">
+ <dt>Name</dt>
+ <dd><c:out value="${pet.name}"/></dd>
+ <dt>Birth Date</dt>
+ <dd><joda:format value="${pet.birthDate}" pattern="yyyy-MM-dd"/></dd>
+ <dt>Type</dt>
+ <dd><c:out value="${pet.type.name}"/></dd>
+ </dl>
+ </td>
+ <td valign="top">
+ <table class="table-condensed">
+ <thead>
+ <tr>
+ <th>Visit Date</th>
+ <th>Description</th>
+ </tr>
+ </thead>
+ <c:forEach var="visit" items="${pet.visits}">
<tr>
- <th>Visit Date</th>
- <th>Description</th>
+ <td><joda:format value="${visit.date}" pattern="yyyy-MM-dd"/></td>
+ <td><c:out value="${visit.description}"/></td>
</tr>
- </thead>
- <c:forEach var="visit" items="${pet.visits}">
- <tr>
- <td><joda:format value="${visit.date}" pattern="yyyy-MM-dd"/></td>
- <td><c:out value="${visit.description}"/></td>
- </tr>
- </c:forEach>
- <tr>
- <td>
- <spring:url value="/owners/{ownerId}/pets/{petId}/edit" var="petUrl">
- <spring:param name="ownerId" value="${owner.id}"/>
- <spring:param name="petId" value="${pet.id}"/>
- </spring:url>
- <a href="${fn:escapeXml(petUrl)}">Edit Pet</a>
- </td>
- <td>
- <spring:url value="/owners/{ownerId}/pets/{petId}/visits/new" var="visitUrl">
- <spring:param name="ownerId" value="${owner.id}"/>
- <spring:param name="petId" value="${pet.id}"/>
- </spring:url>
- <a href="${fn:escapeXml(visitUrl)}">Add Visit</a>
- </td>
- </tr>
- </table>
- </td>
- </tr>
-
- </c:forEach>
- </table>
-
- <petclinic:pivotal/>
- </div>
-</div>
-
-<jsp:include page="../fragments/footer.jsp"/>
+ </c:forEach>
+ <tr>
+ <td>
+ <spring:url value="/owners/{ownerId}/pets/{petId}/edit" var="petUrl">
+ <spring:param name="ownerId" value="${owner.id}"/>
+ <spring:param name="petId" value="${pet.id}"/>
+ </spring:url>
+ <a href="${fn:escapeXml(petUrl)}">Edit Pet</a>
+ </td>
+ <td>
+ <spring:url value="/owners/{ownerId}/pets/{petId}/visits/new" var="visitUrl">
+ <spring:param name="ownerId" value="${owner.id}"/>
+ <spring:param name="petId" value="${pet.id}"/>
+ </spring:url>
+ <a href="${fn:escapeXml(visitUrl)}">Add Visit</a>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
-</body>
+ </c:forEach>
+ </table>
-</html>
+</petclinic:layout>
diff --git a/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp b/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp
index 1824a28..c33f3d2 100644
--- a/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp
+++ b/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp
@@ -1,5 +1,3 @@
-<!DOCTYPE html>
-
<%@ page session="false" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
@@ -8,43 +6,28 @@
<%@ taglib prefix="datatables" uri="http://github.com/dandelion/datatables" %>
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
-<html lang="en">
-
-<jsp:include page="../fragments/htmlHeader.jsp"/>
-
-<body>
-<petclinic:bodyHeader menuName="owners"/>
-<div class="container-fluid">
- <div class="container xd-container">
- <h2>Owners</h2>
-
- <datatables:table id="owners" data="${selections}" row="owner"
- cssClass="table table-striped" pageable="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" cssStyle="height: 25px;"/>
- </datatables:table>
-
- <petclinic:pivotal/>
- </div>
-</div>
-
-<jsp:include page="../fragments/footer.jsp"/>
-</body>
-
-</html>
+<petclinic:layout pageName="owners">
+ <h2>Owners</h2>
+
+ <datatables:table id="owners" data="${selections}" row="owner"
+ cssClass="table table-striped" pageable="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" cssStyle="height: 25px;"/>
+ </datatables:table>
+</petclinic:layout>
diff --git a/src/main/webapp/WEB-INF/jsp/pets/createOrUpdatePetForm.jsp b/src/main/webapp/WEB-INF/jsp/pets/createOrUpdatePetForm.jsp
index e4f20e9..21b651f 100644
--- a/src/main/webapp/WEB-INF/jsp/pets/createOrUpdatePetForm.jsp
+++ b/src/main/webapp/WEB-INF/jsp/pets/createOrUpdatePetForm.jsp
@@ -1,20 +1,18 @@
-<!DOCTYPE html>
-
<%@ page session="false" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
-
-<html lang="en">
-
-<jsp:include page="../fragments/htmlHeader.jsp"/>
-<body>
-<petclinic:bodyHeader menuName="owners"/>
-
-<div class="container-fluid">
- <div class="container xd-container">
+<petclinic:layout pageName="owners">
+ <jsp:attribute name="customScript">
+ <script>
+ $(function () {
+ $("#birthDate").datepicker({dateFormat: 'yy/mm/dd'});
+ });
+ </script>
+ </jsp:attribute>
+ <jsp:body>
<h2>
<c:if test="${pet['new']}">New </c:if> Pet
</h2>
@@ -49,17 +47,5 @@
</form:form>
<c:if test="${!pet['new']}">
</c:if>
-
- <petclinic:pivotal/>
- </div>
-</div>
-<jsp:include page="../fragments/footer.jsp"/>
-
-<script>
- $(function () {
- $("#birthDate").datepicker({dateFormat: 'yy/mm/dd'});
- });
-</script>
-</body>
-
-</html>
+ </jsp:body>
+</petclinic:layout>
diff --git a/src/main/webapp/WEB-INF/jsp/pets/createOrUpdateVisitForm.jsp b/src/main/webapp/WEB-INF/jsp/pets/createOrUpdateVisitForm.jsp
index d1f9017..df70223 100644
--- a/src/main/webapp/WEB-INF/jsp/pets/createOrUpdateVisitForm.jsp
+++ b/src/main/webapp/WEB-INF/jsp/pets/createOrUpdateVisitForm.jsp
@@ -1,6 +1,4 @@
-<!DOCTYPE html>
-
-<%@ page session="false" %>
+<%@ page session="false" trimDirectiveWhitespaces="true" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
@@ -9,15 +7,15 @@
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
-<html lang="en">
-
-<jsp:include page="../fragments/htmlHeader.jsp"/>
-
-<body>
-
-<petclinic:bodyHeader menuName="owners"/>
-<div class="container-fluid">
- <div class="container xd-container">
+<petclinic:layout pageName="owners">
+ <jsp:attribute name="customScript">
+ <script>
+ $(function () {
+ $("#date").datepicker({dateFormat: 'yy/mm/dd'});
+ });
+ </script>
+ </jsp:attribute>
+ <jsp:body>
<h2><c:if test="${visit['new']}">New </c:if>Visit</h2>
<b>Pet</b>
@@ -68,16 +66,6 @@
</c:if>
</c:forEach>
</table>
+ </jsp:body>
- <petclinic:pivotal/>
- </div>
-</div>
-<jsp:include page="../fragments/footer.jsp"/>
-<script>
- $(function () {
- $("#date").datepicker({dateFormat: 'yy/mm/dd'});
- });
-</script>
-</body>
-
-</html>
+</petclinic:layout>
src/main/webapp/WEB-INF/jsp/vets/vetList.jsp 72(+28 -44)
diff --git a/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp b/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp
index e3cdde2..d8e48e8 100644
--- a/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp
+++ b/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp
@@ -1,50 +1,34 @@
-<!DOCTYPE html>
-
-<%@ page session="false" %>
+<%@ page session="false" trimDirectiveWhitespaces="true" %>
<%@ 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" %>
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
-<html lang="en">
-
-<jsp:include page="../fragments/htmlHeader.jsp"/>
-
-<body>
-<petclinic:bodyHeader menuName="vets"/>
-<div class="container-fluid">
- <div class="container xd-container">
- <h2>Veterinarians</h2>
-
- <datatables:table id="vets" data="${vets.vetList}" row="vet" cssClass="table table-striped"
- pageable="false" info="false">
- <datatables:column title="Name">
- <c:out value="${vet.firstName} ${vet.lastName}"/>
- </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>
- <a href="<spring:url value="/vets.xml" htmlEscape="true" />">View as XML</a>
- </td>
- <td>
- <a href="<spring:url value="/vets.json" htmlEscape="true" />">View as JSON</a>
- </td>
- </tr>
- </table>
-
- <petclinic:pivotal/>
- </div>
-</div>
-<jsp:include page="../fragments/footer.jsp"/>
-</body>
-
-</html>
+<petclinic:layout pageName="vets">
+ <h2>Veterinarians</h2>
+
+ <datatables:table id="vets" data="${vets.vetList}" row="vet" cssClass="table table-striped"
+ pageable="false" info="false">
+ <datatables:column title="Name">
+ <c:out value="${vet.firstName} ${vet.lastName}"/>
+ </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>
+ <a href="<spring:url value="/vets.xml" htmlEscape="true" />">View as XML</a>
+ </td>
+ <td>
+ <a href="<spring:url value="/vets.json" htmlEscape="true" />">View as JSON</a>
+ </td>
+ </tr>
+ </table>
+</petclinic:layout>
src/main/webapp/WEB-INF/jsp/welcome.jsp 34(+8 -26)
diff --git a/src/main/webapp/WEB-INF/jsp/welcome.jsp b/src/main/webapp/WEB-INF/jsp/welcome.jsp
index ee99745..b801ec6 100644
--- a/src/main/webapp/WEB-INF/jsp/welcome.jsp
+++ b/src/main/webapp/WEB-INF/jsp/welcome.jsp
@@ -1,32 +1,14 @@
-<!DOCTYPE html>
-
-<%@ page session="false" %>
+<%@ page session="false" trimDirectiveWhitespaces="true" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
-
-<html lang="en">
-
-<jsp:include page="fragments/htmlHeader.jsp"/>
-
-<body>
-<petclinic:bodyHeader menuName="home"/>
-
-<div class="container-fluid">
- <div class="container xd-container">
- <h2><fmt:message key="welcome"/></h2>
- <div class="row">
- <div class="col-md-12">
- <spring:url value="/resources/images/pets.png" htmlEscape="true" var="petsImage"/>
- <img class="img-responsive" src="${petsImage}"/>
- </div>
+<petclinic:layout pageName="home">
+ <h2><fmt:message key="welcome"/></h2>
+ <div class="row">
+ <div class="col-md-12">
+ <spring:url value="/resources/images/pets.png" htmlEscape="true" var="petsImage"/>
+ <img class="img-responsive" src="${petsImage}"/>
</div>
-
- <petclinic:pivotal/>
</div>
-</div>
-<jsp:include page="fragments/footer.jsp"/>
-</body>
-
-</html>
+</petclinic:layout>
src/main/webapp/WEB-INF/tags/layout.tag 27(+27 -0)
diff --git a/src/main/webapp/WEB-INF/tags/layout.tag b/src/main/webapp/WEB-INF/tags/layout.tag
new file mode 100644
index 0000000..870c735
--- /dev/null
+++ b/src/main/webapp/WEB-INF/tags/layout.tag
@@ -0,0 +1,27 @@
+<%@ tag trimDirectiveWhitespaces="true" %>
+<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
+
+<%@ attribute name="pageName" required="true" %>
+<%@ attribute name="customScript" required="false" fragment="true"%>
+
+<!doctype html>
+<html>
+<petclinic:htmlHeader/>
+
+<body>
+<petclinic:bodyHeader menuName="${pageName}"/>
+
+<div class="container-fluid">
+ <div class="container xd-container">
+
+ <jsp:doBody/>
+
+ <petclinic:pivotal/>
+ </div>
+</div>
+<petclinic:footer/>
+<jsp:invoke fragment="customScript" />
+
+</body>
+
+</html>
src/main/webapp/WEB-INF/tags/menu.tag 68(+26 -42)
diff --git a/src/main/webapp/WEB-INF/tags/menu.tag b/src/main/webapp/WEB-INF/tags/menu.tag
index 066f75a..f7e8652 100644
--- a/src/main/webapp/WEB-INF/tags/menu.tag
+++ b/src/main/webapp/WEB-INF/tags/menu.tag
@@ -1,10 +1,9 @@
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
-<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core_1_1" %>
-
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
<%@ attribute name="name" required="true" rtexprvalue="true"
description="Name of the active menu: home, owners, vets or error" %>
-<%-- Static navbar --%>
<nav class="navbar navbar-default" role="navigation">
<div class="container">
<div class="navbar-header">
@@ -18,44 +17,29 @@
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
- <c:choose>
- <c:when test="${name eq 'home'}">
- <c:set var="cssMenu" value="active"/>
- </c:when>
- <c:otherwise>
- <c:set var="cssMenu" value=""/>
- </c:otherwise>
- </c:choose>
- <li class="${cssMenu}"><a href="<spring:url value="/" htmlEscape="true" />"><span class="glyphicon glyphicon-home" aria-hidden="true"></span><span> Home</span></a></li>
- <c:choose>
- <c:when test="${name eq 'owners'}">
- <c:set var="cssMenu" value="active"/>
- </c:when>
- <c:otherwise>
- <c:set var="cssMenu" value=""/>
- </c:otherwise>
- </c:choose>
- <li class="${cssMenu}"><a href="<spring:url value="/owners/find.html" htmlEscape="true" />"><span class="glyphicon glyphicon-search" aria-hidden="true"></span><span> Find owners</span></a></li>
- <c:choose>
- <c:when test="${name eq 'vets'}">
- <c:set var="cssMenu" value="active"/>
- </c:when>
- <c:otherwise>
- <c:set var="cssMenu" value=""/>
- </c:otherwise>
- </c:choose>
- <li class="${cssMenu}"><a href="<spring:url value="/vets.html" htmlEscape="true" />"><span class="glyphicon glyphicon-th-list" aria-hidden="true"></span><span> Veterinarians</span></a></li>
- <c:choose>
- <c:when test="${name eq 'error'}">
- <c:set var="cssMenu" value="active"/>
- </c:when>
- <c:otherwise>
- <c:set var="cssMenu" value=""/>
- </c:otherwise>
- </c:choose>
- <li class="${cssMenu}"><a href="<spring:url value="/oups.html" htmlEscape="true" />"
- title="trigger a RuntimeException to see how it is handled"><span class="glyphicon glyphicon-warning-sign" aria-hidden="true"></span><span> Error</span></a></li>
+
+ <petclinic:menuItem active="${name eq 'home'}" url="/" title="home page">
+ <span class="glyphicon glyphicon-home" aria-hidden="true"></span>
+ <span>Home</span>
+ </petclinic:menuItem>
+
+ <petclinic:menuItem active="${name eq 'owners'}" url="/owners/find.html" title="find owners">
+ <span class="glyphicon glyphicon-search" aria-hidden="true"></span>
+ <span>Find owners</span>
+ </petclinic:menuItem>
+
+ <petclinic:menuItem active="${name eq 'vets'}" url="/vets.html" title="veterinarians">
+ <span class="glyphicon glyphicon-th-list" aria-hidden="true"></span>
+ <span>Veterinarians</span>
+ </petclinic:menuItem>
+
+ <petclinic:menuItem active="${name eq 'error'}" url="/oups.html"
+ title="trigger a RuntimeException to see how it is handled">
+ <span class="glyphicon glyphicon-warning-sign" aria-hidden="true"></span>
+ <span>Error</span>
+ </petclinic:menuItem>
+
</ul>
- </div> <%--/.nav-collapse --%>
- </div> <%--/.container-fluid --%>
+ </div>
+ </div>
</nav>
src/main/webapp/WEB-INF/tags/menuItem.tag 13(+13 -0)
diff --git a/src/main/webapp/WEB-INF/tags/menuItem.tag b/src/main/webapp/WEB-INF/tags/menuItem.tag
new file mode 100644
index 0000000..8c14dbb
--- /dev/null
+++ b/src/main/webapp/WEB-INF/tags/menuItem.tag
@@ -0,0 +1,13 @@
+<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
+<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
+
+<%@ attribute name="active" required="true" rtexprvalue="true" %>
+<%@ attribute name="url" required="true" rtexprvalue="true" %>
+<%@ attribute name="title" required="false" rtexprvalue="true" %>
+
+<li class="${active ? 'active' : ''}">
+ <a href="<spring:url value="${url}" htmlEscape="true" />"
+ title="${fn:escapeXml(title)}">
+ <jsp:doBody/>
+ </a>
+</li>