mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-17 13:05:49 +00:00
Fix #171 Jetty 9 support by removing Dandelion
This commit is contained in:
parent
d5571c0fe4
commit
377ef7e500
6 changed files with 73 additions and 109 deletions
28
pom.xml
28
pom.xml
|
@ -30,10 +30,6 @@
|
||||||
<!-- Others -->
|
<!-- Others -->
|
||||||
<mysql-driver.version>5.1.36</mysql-driver.version>
|
<mysql-driver.version>5.1.36</mysql-driver.version>
|
||||||
|
|
||||||
<!-- Web dependencies -->
|
|
||||||
<dandelion.version>1.1.1</dandelion.version>
|
|
||||||
<dandelion.datatables.version>1.1.0</dandelion.datatables.version>
|
|
||||||
|
|
||||||
<cobertura.version>2.7</cobertura.version>
|
<cobertura.version>2.7</cobertura.version>
|
||||||
|
|
||||||
<jpa.database>HSQL</jpa.database>
|
<jpa.database>HSQL</jpa.database>
|
||||||
|
@ -85,6 +81,14 @@
|
||||||
<artifactId>taglibs-standard-jstlel</artifactId>
|
<artifactId>taglibs-standard-jstlel</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- JSon -->
|
<!-- JSon -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-databind</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.jayway.jsonpath</groupId>
|
<groupId>com.jayway.jsonpath</groupId>
|
||||||
<artifactId>json-path</artifactId>
|
<artifactId>json-path</artifactId>
|
||||||
|
@ -218,22 +222,6 @@
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Dandelion -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.dandelion</groupId>
|
|
||||||
<artifactId>dandelion-jsp</artifactId>
|
|
||||||
<version>${dandelion.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.dandelion</groupId>
|
|
||||||
<artifactId>datatables-jsp</artifactId>
|
|
||||||
<version>${dandelion.datatables.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.dandelion</groupId>
|
|
||||||
<artifactId>datatables-export-itext</artifactId>
|
|
||||||
<version>${dandelion.datatables.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- temporary fix: below dependency should not be necessary as it is a transitive dependency.
|
<!-- temporary fix: below dependency should not be necessary as it is a transitive dependency.
|
||||||
For some reason we can't build the app unless it is a first level dependency -->
|
For some reason we can't build the app unless it is a first level dependency -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -107,15 +107,6 @@ File -> Import -> Maven -> Existing Maven project
|
||||||
<a href="/src/main/webapp/WEB-INF/jsp/fragments/staticFiles.jsp#L12">sample usage in JSP</a></td>
|
<a href="/src/main/webapp/WEB-INF/jsp/fragments/staticFiles.jsp#L12">sample usage in JSP</a></td>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td>Dandelion-datatables</td>
|
|
||||||
<td>
|
|
||||||
<a href="/src/main/webapp/WEB-INF/jsp/owners/ownersList.jsp">ownersList.jsp</a>
|
|
||||||
<a href="/src/main/webapp/WEB-INF/jsp/vets/vetList.jsp">vetList.jsp</a>
|
|
||||||
<a href="/src/main/java/org/springframework/samples/petclinic/PetclinicInitializer.java">PetclinicInitializer.java</a>
|
|
||||||
<a href="/src/main/resources/dandelion/datatables/datatables.properties">datatables.properties</a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>Thymeleaf branch</td>
|
<td>Thymeleaf branch</td>
|
||||||
<td>
|
<td>
|
||||||
|
|
|
@ -15,19 +15,14 @@
|
||||||
*/
|
*/
|
||||||
package org.springframework.samples.petclinic;
|
package org.springframework.samples.petclinic;
|
||||||
|
|
||||||
import com.github.dandelion.core.web.DandelionFilter;
|
|
||||||
import com.github.dandelion.core.web.DandelionServlet;
|
|
||||||
import com.github.dandelion.datatables.core.web.filter.DatatablesFilter;
|
|
||||||
import org.springframework.util.Assert;
|
|
||||||
import org.springframework.web.WebApplicationInitializer;
|
|
||||||
import org.springframework.web.context.WebApplicationContext;
|
import org.springframework.web.context.WebApplicationContext;
|
||||||
import org.springframework.web.context.support.XmlWebApplicationContext;
|
import org.springframework.web.context.support.XmlWebApplicationContext;
|
||||||
import org.springframework.web.filter.CharacterEncodingFilter;
|
import org.springframework.web.filter.CharacterEncodingFilter;
|
||||||
import org.springframework.web.servlet.DispatcherServlet;
|
import org.springframework.web.servlet.DispatcherServlet;
|
||||||
import org.springframework.web.servlet.support.AbstractDispatcherServletInitializer;
|
import org.springframework.web.servlet.support.AbstractDispatcherServletInitializer;
|
||||||
|
|
||||||
import javax.servlet.*;
|
import javax.servlet.Filter;
|
||||||
import java.util.EnumSet;
|
import javax.servlet.ServletContext;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,8 +30,8 @@ import java.util.EnumSet;
|
||||||
* {@link ServletContext} programmatically.
|
* {@link ServletContext} programmatically.
|
||||||
* <p/>
|
* <p/>
|
||||||
* Create the Spring "<strong>root</strong>" application context.<br/>
|
* Create the Spring "<strong>root</strong>" application context.<br/>
|
||||||
* Register a {@link DispatcherServlet} and a {@link DandelionServlet} in the servlet context.<br/>
|
* Register a {@link DispatcherServlet} in the servlet context.<br/>
|
||||||
* For both servlets, register a {@link CharacterEncodingFilter}, a {@link DandelionFilter} an a {@link DatatablesFilter}.
|
* For both servlets, register a {@link CharacterEncodingFilter}.
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @author Antoine Rey
|
* @author Antoine Rey
|
||||||
|
@ -52,14 +47,6 @@ public class PetclinicInitializer extends AbstractDispatcherServletInitializer {
|
||||||
*/
|
*/
|
||||||
private static final String SPRING_PROFILE = "jpa";
|
private static final String SPRING_PROFILE = "jpa";
|
||||||
|
|
||||||
private static final String DANDELION_SERVLET = "dandelionServlet";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStartup(ServletContext servletContext) throws ServletException {
|
|
||||||
super.onStartup(servletContext);
|
|
||||||
registerDandelionServlet(servletContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected WebApplicationContext createRootApplicationContext() {
|
protected WebApplicationContext createRootApplicationContext() {
|
||||||
XmlWebApplicationContext rootAppContext = new XmlWebApplicationContext();
|
XmlWebApplicationContext rootAppContext = new XmlWebApplicationContext();
|
||||||
|
@ -68,7 +55,6 @@ public class PetclinicInitializer extends AbstractDispatcherServletInitializer {
|
||||||
return rootAppContext;
|
return rootAppContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected WebApplicationContext createServletApplicationContext() {
|
protected WebApplicationContext createServletApplicationContext() {
|
||||||
XmlWebApplicationContext webAppContext = new XmlWebApplicationContext();
|
XmlWebApplicationContext webAppContext = new XmlWebApplicationContext();
|
||||||
|
@ -85,27 +71,7 @@ public class PetclinicInitializer extends AbstractDispatcherServletInitializer {
|
||||||
protected Filter[] getServletFilters() {
|
protected Filter[] getServletFilters() {
|
||||||
// Used to provide the ability to enter Chinese characters inside the Owner Form
|
// Used to provide the ability to enter Chinese characters inside the Owner Form
|
||||||
CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter("UTF-8", true);
|
CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter("UTF-8", true);
|
||||||
|
return new Filter[]{characterEncodingFilter};
|
||||||
// Dandelion filter definition and mapping -->
|
|
||||||
DandelionFilter dandelionFilter = new DandelionFilter();
|
|
||||||
|
|
||||||
// Dandelion-Datatables filter, used for basic export -->
|
|
||||||
DatatablesFilter datatablesFilter = new DatatablesFilter();
|
|
||||||
|
|
||||||
return new Filter[]{characterEncodingFilter, dandelionFilter, datatablesFilter};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected FilterRegistration.Dynamic registerServletFilter(ServletContext servletContext, Filter filter) {
|
|
||||||
FilterRegistration.Dynamic registration = super.registerServletFilter(servletContext, filter);
|
|
||||||
registration.addMappingForServletNames(EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.INCLUDE), false, DANDELION_SERVLET);
|
|
||||||
return registration;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void registerDandelionServlet(ServletContext servletContext) {
|
|
||||||
DandelionServlet dandelionServlet = new DandelionServlet();
|
|
||||||
ServletRegistration.Dynamic registration = servletContext.addServlet(DANDELION_SERVLET, dandelionServlet);
|
|
||||||
registration.setLoadOnStartup(2);
|
|
||||||
registration.addMapping("/dandelion-assets/*");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
# ==================================
|
|
||||||
# Dandelion-Datatables configuration
|
|
||||||
# ==================================
|
|
||||||
|
|
||||||
# Disable the asset management of Dandelion-Core for all non-DataTable-related assets
|
|
||||||
main.standalone=true
|
|
|
@ -3,31 +3,46 @@
|
||||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||||
<%@ taglib prefix="datatables" uri="http://github.com/dandelion/datatables" %>
|
|
||||||
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
|
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
|
||||||
|
|
||||||
<petclinic:layout pageName="owners">
|
<petclinic:layout pageName="owners">
|
||||||
<h2>Owners</h2>
|
<h2>Owners</h2>
|
||||||
|
|
||||||
<datatables:table id="owners" data="${selections}" row="owner"
|
<table id="vets" class="table table-striped">
|
||||||
cssClass="table table-striped" pageable="false" info="false" export="pdf">
|
<thead>
|
||||||
<datatables:column title="Name" cssStyle="width: 150px;" display="html">
|
<tr>
|
||||||
<spring:url value="/owners/{ownerId}.html" var="ownerUrl">
|
<th style="width: 150px;">Name</th>
|
||||||
<spring:param name="ownerId" value="${owner.id}"/>
|
<th style="width: 200px;">Address</th>
|
||||||
</spring:url>
|
<th>City</th>
|
||||||
<a href="${fn:escapeXml(ownerUrl)}"><c:out value="${owner.firstName} ${owner.lastName}"/></a>
|
<th style="width: 120px">Telephone</th>
|
||||||
</datatables:column>
|
<th>Pets</th>
|
||||||
<datatables:column title="Name" display="pdf">
|
</tr>
|
||||||
<c:out value="${owner.firstName} ${owner.lastName}"/>
|
</thead>
|
||||||
</datatables:column>
|
<tbody>
|
||||||
<datatables:column title="Address" property="address" cssStyle="width: 200px;"/>
|
<c:forEach items="${selections}" var="owner">
|
||||||
<datatables:column title="City" property="city"/>
|
<tr>
|
||||||
<datatables:column title="Telephone" property="telephone"/>
|
<td>
|
||||||
<datatables:column title="Pets" cssStyle="width: 100px;">
|
<spring:url value="/owners/{ownerId}.html" var="ownerUrl">
|
||||||
<c:forEach var="pet" items="${owner.pets}">
|
<spring:param name="ownerId" value="${owner.id}"/>
|
||||||
<c:out value="${pet.name}"/>
|
</spring:url>
|
||||||
</c:forEach>
|
<a href="${fn:escapeXml(ownerUrl)}"><c:out value="${owner.firstName} ${owner.lastName}"/></a>
|
||||||
</datatables:column>
|
</td>
|
||||||
<datatables:export type="pdf" cssClass="btn" cssStyle="height: 25px;"/>
|
<td>
|
||||||
</datatables:table>
|
<c:out value="${owner.address}"/>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<c:out value="${owner.city}"/>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<c:out value="${owner.telephone}"/>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<c:forEach var="pet" items="${owner.pets}">
|
||||||
|
<c:out value="${pet.name} "/>
|
||||||
|
</c:forEach>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</c:forEach>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
</petclinic:layout>
|
</petclinic:layout>
|
||||||
|
|
|
@ -2,24 +2,34 @@
|
||||||
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
||||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
<%@ 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" %>
|
<%@ taglib prefix="petclinic" tagdir="/WEB-INF/tags" %>
|
||||||
|
|
||||||
<petclinic:layout pageName="vets">
|
<petclinic:layout pageName="vets">
|
||||||
<h2>Veterinarians</h2>
|
<h2>Veterinarians</h2>
|
||||||
|
|
||||||
<datatables:table id="vets" data="${vets.vetList}" row="vet" cssClass="table table-striped"
|
<table id="vets" class="table table-striped">
|
||||||
pageable="false" info="false">
|
<thead>
|
||||||
<datatables:column title="Name">
|
<tr>
|
||||||
<c:out value="${vet.firstName} ${vet.lastName}"/>
|
<th>Name</th>
|
||||||
</datatables:column>
|
<th>Specialties</th>
|
||||||
<datatables:column title="Specialties">
|
</tr>
|
||||||
<c:forEach var="specialty" items="${vet.specialties}">
|
</thead>
|
||||||
<c:out value="${specialty.name}"/>
|
<tbody>
|
||||||
</c:forEach>
|
<c:forEach items="${vets.vetList}" var="vet">
|
||||||
<c:if test="${vet.nrOfSpecialties == 0}">none</c:if>
|
<tr>
|
||||||
</datatables:column>
|
<td>
|
||||||
</datatables:table>
|
<c:out value="${vet.firstName} ${vet.lastName}"/>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<c:forEach var="specialty" items="${vet.specialties}">
|
||||||
|
<c:out value="${specialty.name} "/>
|
||||||
|
</c:forEach>
|
||||||
|
<c:if test="${vet.nrOfSpecialties == 0}">none</c:if>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</c:forEach>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
<table class="table-buttons">
|
<table class="table-buttons">
|
||||||
<tr>
|
<tr>
|
||||||
|
|
Loading…
Reference in a new issue