Fix #171 Jetty 9 support by removing Dandelion

This commit is contained in:
Antoine Rey 2016-10-07 18:21:09 +02:00
parent d5571c0fe4
commit 377ef7e500
6 changed files with 73 additions and 109 deletions

28
pom.xml
View file

@ -30,10 +30,6 @@
<!-- Others -->
<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>
<jpa.database>HSQL</jpa.database>
@ -85,6 +81,14 @@
<artifactId>taglibs-standard-jstlel</artifactId>
</dependency>
<!-- 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>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
@ -218,22 +222,6 @@
<scope>test</scope>
</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.
For some reason we can't build the app unless it is a first level dependency -->
<dependency>

View file

@ -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>
</td>
</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>
<td>Thymeleaf branch</td>
<td>

View file

@ -15,19 +15,14 @@
*/
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.support.XmlWebApplicationContext;
import org.springframework.web.filter.CharacterEncodingFilter;
import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.servlet.support.AbstractDispatcherServletInitializer;
import javax.servlet.*;
import java.util.EnumSet;
import javax.servlet.Filter;
import javax.servlet.ServletContext;
/**
@ -35,8 +30,8 @@ import java.util.EnumSet;
* {@link ServletContext} programmatically.
* <p/>
* Create the Spring "<strong>root</strong>" application context.<br/>
* Register a {@link DispatcherServlet} and a {@link DandelionServlet} in the servlet context.<br/>
* For both servlets, register a {@link CharacterEncodingFilter}, a {@link DandelionFilter} an a {@link DatatablesFilter}.
* Register a {@link DispatcherServlet} in the servlet context.<br/>
* For both servlets, register a {@link CharacterEncodingFilter}.
* <p/>
*
* @author Antoine Rey
@ -52,14 +47,6 @@ public class PetclinicInitializer extends AbstractDispatcherServletInitializer {
*/
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
protected WebApplicationContext createRootApplicationContext() {
XmlWebApplicationContext rootAppContext = new XmlWebApplicationContext();
@ -68,7 +55,6 @@ public class PetclinicInitializer extends AbstractDispatcherServletInitializer {
return rootAppContext;
}
@Override
protected WebApplicationContext createServletApplicationContext() {
XmlWebApplicationContext webAppContext = new XmlWebApplicationContext();
@ -85,27 +71,7 @@ public class PetclinicInitializer extends AbstractDispatcherServletInitializer {
protected Filter[] getServletFilters() {
// Used to provide the ability to enter Chinese characters inside the Owner Form
CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter("UTF-8", true);
// 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};
return new Filter[]{characterEncodingFilter};
}
@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/*");
}
}

View file

@ -1,6 +0,0 @@
# ==================================
# Dandelion-Datatables configuration
# ==================================
# Disable the asset management of Dandelion-Core for all non-DataTable-related assets
main.standalone=true

View file

@ -3,31 +3,46 @@
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ 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" %>
<petclinic:layout pageName="owners">
<h2>Owners</h2>
<datatables:table id="owners" data="${selections}" row="owner"
cssClass="table table-striped" pageable="false" info="false" export="pdf">
<datatables:column title="Name" cssStyle="width: 150px;" display="html">
<spring:url value="/owners/{ownerId}.html" var="ownerUrl">
<spring:param name="ownerId" value="${owner.id}"/>
</spring:url>
<a href="${fn:escapeXml(ownerUrl)}"><c:out value="${owner.firstName} ${owner.lastName}"/></a>
</datatables:column>
<datatables:column title="Name" display="pdf">
<c:out value="${owner.firstName} ${owner.lastName}"/>
</datatables:column>
<datatables:column title="Address" property="address" cssStyle="width: 200px;"/>
<datatables:column title="City" property="city"/>
<datatables:column title="Telephone" property="telephone"/>
<datatables:column title="Pets" cssStyle="width: 100px;">
<c:forEach var="pet" items="${owner.pets}">
<c:out value="${pet.name}"/>
</c:forEach>
</datatables:column>
<datatables:export type="pdf" cssClass="btn" cssStyle="height: 25px;"/>
</datatables:table>
<table id="vets" class="table table-striped">
<thead>
<tr>
<th style="width: 150px;">Name</th>
<th style="width: 200px;">Address</th>
<th>City</th>
<th style="width: 120px">Telephone</th>
<th>Pets</th>
</tr>
</thead>
<tbody>
<c:forEach items="${selections}" var="owner">
<tr>
<td>
<spring:url value="/owners/{ownerId}.html" var="ownerUrl">
<spring:param name="ownerId" value="${owner.id}"/>
</spring:url>
<a href="${fn:escapeXml(ownerUrl)}"><c:out value="${owner.firstName} ${owner.lastName}"/></a>
</td>
<td>
<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>

View file

@ -2,24 +2,34 @@
<%@ 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" %>
<petclinic:layout pageName="vets">
<h2>Veterinarians</h2>
<datatables:table id="vets" data="${vets.vetList}" row="vet" cssClass="table table-striped"
pageable="false" info="false">
<datatables:column title="Name">
<c:out value="${vet.firstName} ${vet.lastName}"/>
</datatables:column>
<datatables:column title="Specialties">
<c:forEach var="specialty" items="${vet.specialties}">
<c:out value="${specialty.name}"/>
</c:forEach>
<c:if test="${vet.nrOfSpecialties == 0}">none</c:if>
</datatables:column>
</datatables:table>
<table id="vets" class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Specialties</th>
</tr>
</thead>
<tbody>
<c:forEach items="${vets.vetList}" var="vet">
<tr>
<td>
<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">
<tr>