petclinic-aplcache
Changes
src/main/resources/log4j.xml 4(+2 -2)
Details
diff --git a/src/main/java/org/springframework/samples/petclinic/Owner.java b/src/main/java/org/springframework/samples/petclinic/Owner.java
index cb24f26..4bf7f09 100644
--- a/src/main/java/org/springframework/samples/petclinic/Owner.java
+++ b/src/main/java/org/springframework/samples/petclinic/Owner.java
@@ -12,9 +12,8 @@ import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Digits;
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Size;
+import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.beans.support.MutableSortDefinition;
import org.springframework.beans.support.PropertyComparator;
import org.springframework.core.style.ToStringCreator;
@@ -30,15 +29,15 @@ import org.springframework.core.style.ToStringCreator;
@Entity @Table(name="owners")
public class Owner extends Person {
@Column(name="address")
- @NotNull @Size(min = 1)
+ @NotEmpty
private String address;
@Column(name="city")
- @NotNull @Size(min = 1)
+ @NotEmpty
private String city;
@Column(name="telephone")
- @NotNull @Digits(fraction = 0, integer = 10)
+ @NotEmpty @Digits(fraction = 0, integer = 10)
private String telephone;
@OneToMany(cascade=CascadeType.ALL, mappedBy="owner")
src/main/resources/log4j.xml 4(+2 -2)
diff --git a/src/main/resources/log4j.xml b/src/main/resources/log4j.xml
index 817cc73..4050665 100755
--- a/src/main/resources/log4j.xml
+++ b/src/main/resources/log4j.xml
@@ -12,7 +12,7 @@
</appender>
<logger name="org.springframework.web">
- <level value="info" />
+ <level value="debug" />
</logger>
<logger name="org.springframework.jdbc">
@@ -24,7 +24,7 @@
</logger>
<logger name="org.hibernate.validator">
- <level value="trace" />
+ <level value="debug" />
</logger>
<!-- Root Logger -->
diff --git a/src/main/webapp/resources/css/petclinic.css b/src/main/webapp/resources/css/petclinic.css
index 8e31eae..590cbe0 100644
--- a/src/main/webapp/resources/css/petclinic.css
+++ b/src/main/webapp/resources/css/petclinic.css
@@ -15,3 +15,7 @@ input[type="text"] {
.navbar .nav > li > a {
color: #000000;
}
+
+ .form-horizontal .control-label {
+ text-align: left;
+}
diff --git a/src/main/webapp/WEB-INF/jsp/fragments/bodyHeader.jsp b/src/main/webapp/WEB-INF/jsp/fragments/bodyHeader.jsp
index 71733bf..f360fec 100644
--- a/src/main/webapp/WEB-INF/jsp/fragments/bodyHeader.jsp
+++ b/src/main/webapp/WEB-INF/jsp/fragments/bodyHeader.jsp
@@ -8,7 +8,7 @@
<ul class="nav">
<li style="width: 100px;"><a href="<spring:url value="/" htmlEscape="true" />"><i class="icon-home"></i> Home</a></li>
<li style="width: 130px;"><a href="<spring:url value="/owners/find.html" htmlEscape="true" />"><i class="icon-search"></i> Find owners</a></li>
- <li style="width: 120px;"><a href="<spring:url value="/vets.html" htmlEscape="true" />"><i class="icon-th-list"></i> Veterinarians</a></li>
+ <li style="width: 130px;"><a href="<spring:url value="/vets.html" htmlEscape="true" />"><i class="icon-th-list"></i> Veterinarians</a></li>
<li style="width: 100px;"><a href="<spring:url value="/resources/html/tutorial.html" htmlEscape="true" />"><i class=" icon-question-sign"></i> Tutorial</a></li>
<li style="width: 80px;"><a href="<spring:url value="/oups.html" htmlEscape="true" />" title="trigger a RuntimeException to see how it is handled"><i class="icon-warning-sign"></i> Error</a></li>
</ul>
diff --git a/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp b/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp
index 763aac0..87025b8 100644
--- a/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp
+++ b/src/main/webapp/WEB-INF/jsp/owners/createOrUpdateOwnerForm.jsp
@@ -22,41 +22,56 @@
</h2>
<form:form modelAttribute="owner" method="${method}" class="form-horizontal" id="add-owner-form">
<fieldset>
- <div class="control-group" id="firstName">
- <label class="control-label">First Name </label>
- <div class="controls">
- <form:input path="firstName" />
- <span class="help-inline"><form:errors path="firstName" /></span>
+ <spring:bind path="firstName">
+ <c:set var="cssGroup" value="control-group ${status.error ? 'error' : '' }"/>
+ <div class="${cssGroup}" id="${firstName}">
+ <label class="control-label">First Name</label>
+ <div class="controls">
+ <form:input path="firstName"/>
+ <span class="help-inline">${status.errorMessage}</span>
+ </div>
</div>
- </div>
- <div class="control-group" id="lastName">
- <label class="control-label">Last Name </label>
- <div class="controls">
- <form:input path="lastName" />
- <span class="help-inline"><form:errors path="lastName" /></span>
+ </spring:bind>
+ <spring:bind path="firstName">
+ <c:set var="cssGroup" value="control-group ${status.error ? 'error' : '' }"/>
+ <div class="${cssGroup}" id="${lastName}">
+ <label class="control-label">Last Name</label>
+ <div class="controls">
+ <form:input path="lastName"/>
+ <span class="help-inline">${status.errorMessage}</span>
+ </div>
</div>
- </div>
- <div class="control-group" id="address">
- <label class="control-label">Address </label>
- <div class="controls">
- <form:input path="address" />
- <span class="help-inline"><form:errors path="address" /></span>
+ </spring:bind>
+ <spring:bind path="address">
+ <c:set var="cssGroup" value="control-group ${status.error ? 'error' : '' }"/>
+ <div class="${cssGroup}" id="${address}">
+ <label class="control-label">Address</label>
+ <div class="controls">
+ <form:input path="address"/>
+ <span class="help-inline">${status.errorMessage}</span>
+ </div>
</div>
- </div>
- <div class="control-group" id="city">
- <label class="control-label">City </label>
- <div class="controls">
- <form:input path="city" />
- <span class="help-inline"><form:errors path="city" /></span>
+ </spring:bind>
+ <spring:bind path="city">
+ <c:set var="cssGroup" value="control-group ${status.error ? 'error' : '' }"/>
+ <div class="${cssGroup}" id="${city}">
+ <label class="control-label">City</label>
+ <div class="controls">
+ <form:input path="city"/>
+ <span class="help-inline">${status.errorMessage}</span>
+ </div>
</div>
- </div>
- <div class="control-group" id="telephone">
- <label class="control-label">Telephone </label>
- <div class="controls">
- <form:input path="telephone" />
- <span class="help-inline"><form:errors path="telephone" /></span>
+ </spring:bind>
+ <spring:bind path="telephone">
+ <c:set var="cssGroup" value="control-group ${status.error ? 'error' : '' }"/>
+ <div class="${cssGroup}" id="${telephone}">
+ <label class="control-label">Telephone</label>
+ <div class="controls">
+ <form:input path="telephone"/>
+ <span class="help-inline">${status.errorMessage}</span>
+ </div>
</div>
- </div>
+ </spring:bind>
<div class="form-actions">
<c:choose>
<c:when test="${owner['new']}">
diff --git a/src/main/webapp/WEB-INF/jsp/pets/createOrUpdatePetForm.jsp b/src/main/webapp/WEB-INF/jsp/pets/createOrUpdatePetForm.jsp
index 3ee7cae..b118a6f 100644
--- a/src/main/webapp/WEB-INF/jsp/pets/createOrUpdatePetForm.jsp
+++ b/src/main/webapp/WEB-INF/jsp/pets/createOrUpdatePetForm.jsp
@@ -1,43 +1,74 @@
-<%@ 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="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"%>
<html lang="en">
-
+<jsp:include page="../fragments/headTag.jsp"/>
<body>
- <head>
- <spring:url value="/webjars/jquery/1.8.2/jquery.js" var="jQuery" />
- <script src="${jQuery}"></script>
-
- <spring:url value="/webjars/jquery-ui/1.9.1/js/jquery-ui-1.9.1.custom.js" var="jQueryUi" />
- <script src="${jQueryUi}"></script>
-
- <spring:url value="/webjars/jquery-ui/1.9.1/css/smoothness/jquery-ui-1.9.1.custom.css" var="jQueryUiCss" />
- <link href="${jQueryUiCss}" rel="stylesheet"></link>
-
-
- </head>
- <div class="container">
-
+
<script>
- $(function() {
- $( "#birthDate" ).datepicker();
- });
- </script>
- <form:form modelAttribute="pet" class="form-horizontal">
- <fieldset>
- <div class="control-group" id="birthDate">
- <label class="control-label">Birth Date</label>
- <div class="controls">
- <form:input path="birthDate" />
- </div>
- </div>
+ $(function() {
+ $("#birthDate").datepicker();
+ });
+</script>
+ <div class="container">
+ <jsp:include page="../fragments/bodyHeader.jsp" />
+ <c:choose>
+ <c:when test="${pet['new']}">
+ <c:set var="method" value="post" />
+ </c:when>
+ <c:otherwise>
+ <c:set var="method" value="put" />
+ </c:otherwise>
+ </c:choose>
+
+ <h2>
+ <c:if test="${pet['new']}">New </c:if>
+ Pet
+ </h2>
+
+ <form:form modelAttribute="pet" method="${method}"
+ class="form-horizontal">
+ <div class="control-group" id="owner">
+ <label class="control-label">Owner </label>
- </fieldset>
- </form:form>
- </div>
+ <c:out value="${pet.owner.firstName} ${pet.owner.lastName}"/>
+ </div>
+ <div class="control-group">
+ <label class="control-label">Name </label>
+ <div class="controls">
+ <form:input path="name" />
+ <span class="help-inline"><form:errors path="name" /></span>
+ </div>
+ </div>
+ <div class="control-group">
+ <label class="control-label">Birth Date (yyyy-MM-dd)</label>
+ <div class="controls">
+ <form:input path="birthDate" />
+ <span class="help-inline"><form:errors path="birthDate" /></span>
+ </div>
+ </div>
+ <div class="control-group">
+ <label class="control-label">Type </label>
+ <form:select path="type" items="${types}" size="5"/>
+ </div>
+ <div class="form-actions">
+ <c:choose>
+ <c:when test="${pet['new']}">
+ <button type="submit">Add Pet</button>
+ </c:when>
+ <c:otherwise>
+ <button type="submit">Update Pet</button>
+ </c:otherwise>
+ </c:choose>
+ </div>
+ </form:form>
+ <c:if test="${!pet['new']}">
+ </c:if>
+ <jsp:include page="../fragments/footer.jsp" />
+ </div>
</body>
</html>