From aa8cc431ebf0b1f976afc53fba23f7b01aed1b54 Mon Sep 17 00:00:00 2001 From: Dapeng Date: Mon, 27 Jun 2016 17:06:47 +0800 Subject: [PATCH] simplify jsp layout management MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit abstract the page layout into “layout.tag” --- src/main/webapp/WEB-INF/jsp/exception.jsp | 34 +--- .../jsp/owners/createOrUpdateOwnerForm.jsp | 66 +++---- .../webapp/WEB-INF/jsp/owners/findOwners.jsp | 57 ++---- .../WEB-INF/jsp/owners/ownerDetails.jsp | 183 ++++++++---------- .../webapp/WEB-INF/jsp/owners/ownersList.jsp | 65 +++---- .../jsp/pets/createOrUpdatePetForm.jsp | 36 ++-- .../jsp/pets/createOrUpdateVisitForm.jsp | 36 ++-- src/main/webapp/WEB-INF/jsp/vets/vetList.jsp | 68 +++---- src/main/webapp/WEB-INF/jsp/welcome.jsp | 34 +--- src/main/webapp/WEB-INF/tags/layout.tag | 27 +++ src/main/webapp/WEB-INF/tags/menu.tag | 66 +++---- src/main/webapp/WEB-INF/tags/menuItem.tag | 13 ++ 12 files changed, 281 insertions(+), 404 deletions(-) create mode 100644 src/main/webapp/WEB-INF/tags/layout.tag create mode 100644 src/main/webapp/WEB-INF/tags/menuItem.tag diff --git a/src/main/webapp/WEB-INF/jsp/exception.jsp b/src/main/webapp/WEB-INF/jsp/exception.jsp index 21932524d..d030d595d 100644 --- a/src/main/webapp/WEB-INF/jsp/exception.jsp +++ b/src/main/webapp/WEB-INF/jsp/exception.jsp @@ -1,34 +1,14 @@ - - -<%@ 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" %> - - + - - -
-
+ + - - +

Something happened...

-

Something happened...

+

${exception.message}

-

${exception.message}

- - - -
-
- - - - +
diff --git a/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp b/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp index d5cf881f6..d0aa9d5a2 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 @@ - - <%@ 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" %> - - - - - - - -
-
-

- New Owner -

- -
- - - - - + +

+ New Owner +

+ +
+ + + + + +
+
+
+ + + + + + + +
-
-
- - - - - - - - -
-
- - -
-
- - - - +
+ + diff --git a/src/main/webapp/WEB-INF/jsp/owners/findOwners.jsp b/src/main/webapp/WEB-INF/jsp/owners/findOwners.jsp index e8f61dbcd..13b9a3dfa 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 @@ - - <%@ 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" %> - + - +

Find Owners

- - -
-
- -

Find Owners

- - - -
-
- -
- - -
+ + +
+
+ +
+ +
-
-
- -
+
+
+
+
+
- + -
- Add Owner - - -
-
- - - - - +
+ Add Owner + diff --git a/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp b/src/main/webapp/WEB-INF/jsp/owners/ownerDetails.jsp index 88af6b4d1..3cfbddede 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 @@ - - <%@ 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" %> - + - - - - -
-
- -

Owner Information

+

Owner Information

- +
+ + + + + + + + + + + + + + + + +
Name
Address
City
Telephone
+ + + + + Edit Owner + + + + + Add New Pet + +
+
+
+

Pets and Visits

+ + + + - - - - - - - - - - - - - - - -
Name
Address
City
Telephone
- - - - - Edit Owner - - - - - Add New Pet - -
-
-
-

Pets and Visits

- - - - - - - + - -
-
-
Name
-
-
Birth Date
-
-
Type
-
-
-
- - + + - + + + + + +
+
+
Name
+
+
Birth Date
+
+
Type
+
+
+
+ + + + + + + + - - + + - - - - - - - - - - - -
Visit DateDescription
Visit DateDescription
- - - - - Edit Pet - - - - - - Add Visit -
-
+ + + + + Edit Pet + + + + + + Add Visit +
+
+ + - -
-
- - - - - - +
diff --git a/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp b/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp index 65e17e1c6..c33f3d265 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 @@ - - <%@ 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" %> - + +

Owners

- - - - -
-
-

Owners

- - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - - + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/webapp/WEB-INF/jsp/pets/createOrUpdatePetForm.jsp b/src/main/webapp/WEB-INF/jsp/pets/createOrUpdatePetForm.jsp index c098056d8..21b651f71 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 @@ - - <%@ 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" %> - - - - - - - -
-
+ + + + +

New Pet

@@ -49,17 +47,5 @@ - - -
-
- - - - - - + + diff --git a/src/main/webapp/WEB-INF/jsp/pets/createOrUpdateVisitForm.jsp b/src/main/webapp/WEB-INF/jsp/pets/createOrUpdateVisitForm.jsp index abcd42eae..df70223c0 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 @@ - - -<%@ 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" %> - - - - - - - -
-
+ + + + +

New Visit

Pet @@ -68,16 +66,6 @@ +
- -
-
- - - - - + diff --git a/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp b/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp index 3d1255e12..d8e48e853 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 @@ - - -<%@ 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" %> - + +

Veterinarians

- + + + + + + + + + none + + - - -
-
-

Veterinarians

- - - - - - - - - - none - - - - - - - - -
- ">View as XML - - ">View as JSON -
- - -
-
- - - - + + + + + +
+ ">View as XML + + ">View as JSON +
+
diff --git a/src/main/webapp/WEB-INF/jsp/welcome.jsp b/src/main/webapp/WEB-INF/jsp/welcome.jsp index 23b258f02..b801ec67d 100644 --- a/src/main/webapp/WEB-INF/jsp/welcome.jsp +++ b/src/main/webapp/WEB-INF/jsp/welcome.jsp @@ -1,32 +1,14 @@ - - -<%@ 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" %> - - - - - - - - -
-
-

-
-
- - -
+ +

+
+
+ +
- -
-
- - - - + 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 000000000..870c735b2 --- /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"%> + + + + + + + + +
+
+ + + + +
+
+ + + + + + diff --git a/src/main/webapp/WEB-INF/tags/menu.tag b/src/main/webapp/WEB-INF/tags/menu.tag index 933bd0515..f7e8652b2 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" %> - +<%@ 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 --%>
+
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 000000000..8c14dbbc5 --- /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" %> + +
  • + " + title="${fn:escapeXml(title)}"> + + +