Spring MVC config and layout in 'vets' section

- commented out all Spring MVC config related to content negociation so
the app works well in HTML for now
- Integrated Bootsrap look&Feel in the 'vets' section
This commit is contained in:
Mic 2013-01-14 11:32:32 +08:00
parent 9a77b56427
commit 099847cf49
5 changed files with 82 additions and 91 deletions

View file

@ -10,11 +10,9 @@
<jsp:include page="../header.jsp"/> <jsp:include page="../header.jsp"/>
<body> <body>
<div id="header well"> <div class="container" style="padding-top: 50px;">
<spring:url value="/resources/images/banner-graphic.png" var="banner"/> <spring:url value="/resources/images/banner-graphic.png" var="banner"/>
<img src="${banner}" /> <img src="${banner}" />
</div>
<div class="container" style="padding-top: 50px;">
<c:choose> <c:choose>
<c:when test="${owner['new']}"><c:set var="method" value="post"/></c:when> <c:when test="${owner['new']}"><c:set var="method" value="post"/></c:when>
<c:otherwise><c:set var="method" value="put"/></c:otherwise> <c:otherwise><c:set var="method" value="put"/></c:otherwise>

View file

@ -92,7 +92,7 @@
<table class="table-buttons"> <table class="table-buttons">
<tr> <tr>
<td> <td>
<spring:url value="{ownerId}/pets/{petId}/edit" var="petUrl"> <spring:url value="/owners/{ownerId}/pets/{petId}/edit" var="petUrl">
<spring:param name="ownerId" value="${owner.id}"/> <spring:param name="ownerId" value="${owner.id}"/>
<spring:param name="petId" value="${pet.id}"/> <spring:param name="petId" value="${pet.id}"/>
</spring:url> </spring:url>
@ -100,7 +100,7 @@
</td> </td>
<td></td> <td></td>
<td> <td>
<spring:url value="{ownerId}/pets/{petId}/visits/new" var="visitUrl"> <spring:url value="/owners/{ownerId}/pets/{petId}/visits/new" var="visitUrl">
<spring:param name="ownerId" value="${owner.id}"/> <spring:param name="ownerId" value="${owner.id}"/>
<spring:param name="petId" value="${pet.id}"/> <spring:param name="petId" value="${pet.id}"/>
</spring:url> </spring:url>
@ -108,7 +108,7 @@
</td> </td>
<td></td> <td></td>
<td> <td>
<spring:url value="{ownerId}/pets/{petId}/visits.atom" var="feedUrl"> <spring:url value="/owners/{ownerId}/pets/{petId}/visits.atom" var="feedUrl">
<spring:param name="ownerId" value="${owner.id}"/> <spring:param name="ownerId" value="${owner.id}"/>
<spring:param name="petId" value="${pet.id}"/> <spring:param name="petId" value="${pet.id}"/>
</spring:url> </spring:url>

View file

@ -12,6 +12,7 @@
<div class="container"> <div class="container">
<spring:url value="/resources/images/banner-graphic.png" var="banner"/> <spring:url value="/resources/images/banner-graphic.png" var="banner"/>
<img src="${banner}" /> <img src="${banner}" />
<c:choose> <c:choose>
<c:when test="${pet['new']}"><c:set var="method" value="post"/></c:when> <c:when test="${pet['new']}"><c:set var="method" value="post"/></c:when>
<c:otherwise><c:set var="method" value="put"/></c:otherwise> <c:otherwise><c:set var="method" value="put"/></c:otherwise>
@ -22,49 +23,42 @@
<b>Owner:</b> ${pet.owner.firstName} ${pet.owner.lastName} <b>Owner:</b> ${pet.owner.firstName} ${pet.owner.lastName}
<br/> <br/>
<form:form modelAttribute="pet" method="${method}"> <form:form modelAttribute="pet" method="${method}">
<table> <fieldset>
<tr> <div class="control-group" id="name">
<th> <label class="control-label">Name </label>
Name: <form:errors path="name" cssClass="errors"/> <div class="controls">
<br/> <form:input path="name" />
<form:input path="name" size="30" maxlength="30"/> <span class="help-inline"><form:errors path="name" /></span>
</th> </div>
</tr> </div>
<tr> <div class="control-group" id="birthDate">
<th> <label class="control-label">Birth Date </label>
Birth Date: <form:errors path="birthDate" cssClass="errors"/> <div class="controls">
<br/> <form:input path="birthDate" />
<form:input path="birthDate" size="10" maxlength="10"/> (yyyy-mm-dd) <span class="help-inline"><form:errors path="birthDate" /></span>
</th> </div>
</tr> </div>
<tr> <div class="control-group" id="type">
<th> <label class="control-label">Type </label>
Type: <form:errors path="type" cssClass="errors"/> <form:select path="type" items="${types}"/>
<br/> </div>
<form:select path="type" items="${types}"/> <div class="form-actions">
</th> <c:choose>
</tr> <c:when test="${owner['new']}">
<tr> <button type="submit">Add Pet</button>
<td> </c:when>
<c:choose> <c:otherwise>
<c:when test="${pet['new']}"> <button type="submit">Update Pet</button>
<p class="submit"><input type="submit" value="Add Pet"/></p> </c:otherwise>
</c:when> </c:choose>
<c:otherwise> </div>
<p class="submit"><input type="submit" value="Update Pet"/></p> </fieldset>
</c:otherwise> </form:form>
</c:choose> <c:if test="${!pet['new']}">
</td> <form:form method="delete">
</tr> <p class="submit"><input type="submit" value="Delete Pet"/></p>
</table> </form:form>
</form:form> </c:if>
<c:if test="${!pet['new']}">
<form:form method="delete">
<p class="submit"><input type="submit" value="Delete Pet"/></p>
</form:form>
</c:if>
</div> </div>
<jsp:include page="../footer.jsp"/> <jsp:include page="../footer.jsp"/>
</body> </body>

View file

@ -15,7 +15,7 @@
<h2>Veterinarians</h2> <h2>Veterinarians</h2>
<table> <table class="table table-stripped" style="width:600px;">
<thead> <thead>
<tr> <tr>
<th>Name</th> <th>Name</th>
@ -44,8 +44,8 @@
</tr> </tr>
</table> </table>
<jsp:include page="footer.jsp"/>
</div> </div>
<jsp:include page="footer.jsp"/>
</body> </body>
</html> </html>

View file

@ -14,23 +14,42 @@
- The controllers are autodetected POJOs labeled with the @Controller annotation. - The controllers are autodetected POJOs labeled with the @Controller annotation.
--> -->
<context:component-scan base-package="org.springframework.samples.petclinic.web"/> <context:component-scan base-package="org.springframework.samples.petclinic.web"/>
<!--
- The form-based controllers within this application provide @RequestMapping <mvc:annotation-driven />
- annotations at the type level for path mapping URLs and @RequestMapping <!-- <mvc:annotation-driven content-negotiation-manager="contentNegotiationManager" /> -->
- at the method level for request type mappings (e.g., GET and POST).
- In contrast, ClinicController - which is not form-based - provides <!-- all resources inside folder src/main/webapp/resources are mapped so they can be refered to inside JSP files
- @RequestMapping only at the method level for path mapping URLs. (see header.jsp for more details) -->
- <mvc:resources mapping="/resources/**" location="/resources/"/>
- DefaultAnnotationHandlerMapping is driven by these annotations and is
- enabled by default with Java 5+. <!-- uses WebJars so Javascript and CSS libs can be declared as Maven dependencies (we're using it for Bootstrap) -->
--> <mvc:resources mapping="/webjars/**" location="classpath:/META-INF/resources/webjars/"/>
<!-- <!--
- This bean processes annotated handler methods, applying PetClinic-specific PropertyEditors
- for request parameter binding. It overrides the default AnnotationMethodHandlerAdapter. - This bean configures the 'prefix' and 'suffix' properties of
- InternalResourceViewResolver, which resolves logical view names
- returned by Controllers. For example, a logical view name of "vets"
- will be mapped to "/WEB-INF/jsp/vets.jsp".
--> -->
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/jsp/"
p:suffix=".jsp" />
<!--
- Message source for this context, loaded from localized "messages_xx" files.
- Files are stored inside src/main/resources
-->
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"
p:basename="messages"/>
<!--
Processes annotated handler methods, applying PetClinic-specific request parameter binding.
-->
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
<property name="webBindingInitializer"> <property name="webBindingInitializer">
<bean class="org.springframework.samples.petclinic.web.ClinicBindingInitializer"/> <bean class="org.springframework.samples.petclinic.web.ClinicBindingInitializer"/>
</property> </property>
@ -61,14 +80,9 @@
- property of the vets view bean, setting it to 'application/vnd.springsource.samples.petclinic+xml'. - property of the vets view bean, setting it to 'application/vnd.springsource.samples.petclinic+xml'.
--> -->
<mvc:annotation-driven content-negotiation-manager="contentNegotiationManager" />
<mvc:resources mapping="/resources/**" location="/resources/"/>
<mvc:resources mapping="/webjars/**" location="classpath:/META-INF/resources/webjars/"/>
<bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean"> <!-- <bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
<property name="favorPathExtension" value="false" /> <property name="favorPathExtension" value="false" />
<property name="favorParameter" value="true" /> <property name="favorParameter" value="true" />
<property name="mediaTypes"> <property name="mediaTypes">
@ -78,7 +92,7 @@
xml=application/xml xml=application/xml
</value> </value>
</property> </property>
</bean> </bean> -->
<!-- <!--
@ -87,21 +101,12 @@
- be the first view resolver to be used after the delegating content - be the first view resolver to be used after the delegating content
- negotiating view resolver. - negotiating view resolver.
--> -->
<bean class="org.springframework.web.servlet.view.BeanNameViewResolver" /> <!-- <bean class="org.springframework.web.servlet.view.BeanNameViewResolver" /> -->
<!--
- This bean configures the 'prefix' and 'suffix' properties of
- InternalResourceViewResolver, which resolves logical view names
- returned by Controllers. For example, a logical view name of "vets"
- will be mapped to "/WEB-INF/jsp/vets.jsp".
-->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/jsp/"
p:suffix=".jsp" />
<!-- - The AtomView rendering a Atom feed of the visits --> <!-- - The AtomView rendering a Atom feed of the visits -->
<bean id="visits" class="org.springframework.samples.petclinic.web.VisitsAtomView"/> <!-- <bean id="visits" class="org.springframework.samples.petclinic.web.VisitsAtomView"/>
<bean id="vets" class="org.springframework.web.servlet.view.xml.MarshallingView"> <bean id="vets" class="org.springframework.web.servlet.view.xml.MarshallingView">
<property name="contentType" value="application/vnd.springsource.samples.petclinic+xml"/> <property name="contentType" value="application/vnd.springsource.samples.petclinic+xml"/>
@ -110,14 +115,8 @@
<oxm:jaxb2-marshaller id="marshaller"> <oxm:jaxb2-marshaller id="marshaller">
<oxm:class-to-be-bound name="org.springframework.samples.petclinic.Vets"/> <oxm:class-to-be-bound name="org.springframework.samples.petclinic.Vets"/>
</oxm:jaxb2-marshaller> </oxm:jaxb2-marshaller> -->
<!--
- Message source for this context, loaded from localized "messages_xx" files.
- Could also reside in the root application context, as it is generic,
- but is currently just used within PetClinic's web tier.
-->
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"
p:basename="messages"/>
</beans> </beans>