diff --git a/spring-mvc-demo/WebContent/WEB-INF/view/customer-confirmation.jsp b/spring-mvc-demo/WebContent/WEB-INF/view/customer-confirmation.jsp index f7b5e23..1139321 100644 --- a/spring-mvc-demo/WebContent/WEB-INF/view/customer-confirmation.jsp +++ b/spring-mvc-demo/WebContent/WEB-INF/view/customer-confirmation.jsp @@ -10,5 +10,9 @@ The customer is confirmed: ${ customer.firstName } ${ customer.lastName } +
+ +Free passes: ${ customer.freePasses } + \ No newline at end of file diff --git a/spring-mvc-demo/WebContent/WEB-INF/view/customer-form.jsp b/spring-mvc-demo/WebContent/WEB-INF/view/customer-form.jsp index c9dae15..f895bfa 100644 --- a/spring-mvc-demo/WebContent/WEB-INF/view/customer-form.jsp +++ b/spring-mvc-demo/WebContent/WEB-INF/view/customer-form.jsp @@ -27,6 +27,11 @@ Fill out the form. Asterisk(*) means required.
+ Free passes: + + +
+ diff --git a/spring-mvc-demo/src/com/luv2code/springdemo/mvc/Customer.java b/spring-mvc-demo/src/com/luv2code/springdemo/mvc/Customer.java index 9296626..b4c05e7 100644 --- a/spring-mvc-demo/src/com/luv2code/springdemo/mvc/Customer.java +++ b/spring-mvc-demo/src/com/luv2code/springdemo/mvc/Customer.java @@ -1,5 +1,7 @@ package com.luv2code.springdemo.mvc; +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; @@ -10,6 +12,10 @@ public class Customer { @NotNull(message="is required") @Size(min=1, message="is required") private String lastName; + + @Min(value=0, message="must be greater than or equal to zero") + @Max(value=10, message="must be less than or equal to 10") + private int freePasses; public String getFirstName() { return firstName; @@ -27,4 +33,12 @@ public void setLastName(String lastName) { this.lastName = lastName; } + public int getFreePasses() { + return freePasses; + } + + public void setFreePasses(int freePasses) { + this.freePasses = freePasses; + } + }